Skip to content

Commit

Permalink
Merge pull request #55 from amank22/rel_1.0.3
Browse files Browse the repository at this point in the history
Release v1.0.3
  • Loading branch information
amank22 authored Jan 14, 2022
2 parents 24113b7 + b51e083 commit 5131c49
Show file tree
Hide file tree
Showing 16 changed files with 319 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:

- name: Gradle Build
id: gradle-build
run: ./gradlew repackageUberJar package -PSENTRY_ENDPOINT=${{ env.SENTRY_ENDPOINT }} -PSENTRY_DEBUG=${{ env.SENTRY_DEBUG }}
run: ./gradlew repackageUberJar package -PSENTRY_ENDPOINT=${{ env.SENTRY_ENDPOINT }} -PSENTRY_DEBUG=${{ env.SENTRY_DEBUG }} -PAPP_VERSION=${{github.ref_name}}

- name: Uploading ${{ matrix.os }} uber jar
if: steps.gradle-build.outcome == 'success'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/buildPreProd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Gradle Build
id: gradle-build
run: ./gradlew package -PSENTRY_ENDPOINT=${{ env.SENTRY_ENDPOINT }}
run: ./gradlew repackageUberJar package -PSENTRY_ENDPOINT=${{ env.SENTRY_ENDPOINT }}

- name: Uploading ${{ matrix.os }} uber jar
if: steps.gradle-build.outcome == 'success'
Expand Down
2 changes: 1 addition & 1 deletion .idea/runConfigurations/logvue__run_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,28 @@ plugins {
}

val r8: Configuration by configurations.creating
fun appVersion() : String {
val key = "APP_VERSION"
return if (project.hasProperty(key)) {
val version = project.property("APP_VERSION").toString()
println("Version = $version")
if (version.isBlank()) {
return "1.0.0"
}
if (version.matches(Regex("^[\\d]{1,3}.[\\d]{1,3}.[\\d]{1,4}"))) {
return version
}
if (version.matches(Regex("^v[\\d]{1,3}.[\\d]{1,3}.[\\d]{1,4}"))) {
return version.removePrefix("v")
}
"1.0.0"
} else {
"1.0.0"
}
}

group = "com.voxfinite"
version = "1.0.0"
version = appVersion()

repositories {
google()
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/app/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package app
import androidx.compose.ui.window.application

fun main() = application(false) {
val environment = System.getenv("SKIKO_RENDER_API")
val property = System.getProperty("skiko.renderApi")
println("env: $environment render: $property")
// val environment = System.getenv("SKIKO_RENDER_API")
// val property = System.getProperty("skiko.renderApi")
// println("env: $environment render: $property")
appWindow()
}
3 changes: 2 additions & 1 deletion src/main/kotlin/models/SessionInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import java.io.Serializable

data class SessionInfo(
val description: String,
val appPackage: String
val appPackage: String,
val configs: HashMap<String, String>? = hashMapOf()
) : Serializable {
companion object {
private const val serialVersionUID = 1L
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/processor/MainProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ class MainProcessor {
val sentryTransaction = Sentry.startTransaction("filterLogs", "filter", true)
sentryTransaction.setData("query", filterQuery ?: "")
try {
filterLogs(indexedCollection, list, parser, fQuery)
val fl = filterLogs(indexedCollection, list, parser, fQuery)
sentryTransaction.status = SpanStatus.OK
fl
} catch (e: Exception) {
e.reportException()
sentryTransaction.throwable = e
Expand Down
33 changes: 23 additions & 10 deletions src/main/kotlin/processor/QueryHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import com.googlecode.cqengine.index.radixinverted.InvertedRadixTreeIndex
import com.googlecode.cqengine.index.radixreversed.ReversedRadixTreeIndex
import com.googlecode.cqengine.query.parser.sql.SQLParser
import models.LogItem
import storage.SessionConfig
import utils.AppLog
import utils.ConfigConstants
import utils.reportException
import kotlin.reflect.KProperty1
import kotlin.time.ExperimentalTime
Expand Down Expand Up @@ -66,9 +68,10 @@ fun registerPropertiesInParser(
parser: SQLParser<LogItem>,
indexedCollection: ConcurrentIndexedCollection<LogItem>
) {
val addIndex = SessionConfig.boolDefaultOn(ConfigConstants.QUERY_INDEX)
val propertySet = hashSetOf<String>()
list.forEach {
registerMapPropertiesInParser(it.properties, propertySet, parser, indexedCollection)
registerMapPropertiesInParser(it.properties, propertySet, parser, indexedCollection, addIndex)
}
}

Expand All @@ -77,18 +80,19 @@ private fun registerMapPropertiesInParser(
propertySet: HashSet<String>,
parser: SQLParser<LogItem>,
indexedCollection: ConcurrentIndexedCollection<LogItem>,
addIndex: Boolean,
parentKey: String = ""
) {
properties.forEach { (k, v) ->
if (!propertySet.contains(k)) {
if (v is Map<*, *>) {
@Suppress("UNCHECKED_CAST") registerMapPropertiesInParser(
v as Map<String, Any>, propertySet, parser, indexedCollection, "$parentKey$k."
v as Map<String, Any>, propertySet, parser, indexedCollection, addIndex, "$parentKey$k."
)
} else {
// println("Attribute : ${att.attributeName} with first value = $v and v class = ${v.javaClass.name}")
val key = "$parentKey$k"
registerAndAddIndex(v, key, parser, indexedCollection)
registerAndAddIndex(v, key, parser, indexedCollection, addIndex)
propertySet.add(k)
}
} else {
Expand All @@ -101,11 +105,17 @@ fun registerAndAddIndex(
value: Any,
key: String,
parser: SQLParser<LogItem>,
indexedCollection: ConcurrentIndexedCollection<LogItem>
indexedCollection: ConcurrentIndexedCollection<LogItem>,
addIndex: Boolean
) {
with(indexedCollection) {
if (!addIndex) {
addGenericAttribute(key, value, parser, false)
return
}
if (key.isBlank()) {
addGenericAttribute(key, value, parser)
return
}
when (value) {
is String -> {
Expand Down Expand Up @@ -147,14 +157,17 @@ fun registerAndAddIndex(
private fun ConcurrentIndexedCollection<LogItem>.addGenericAttribute(
key: String,
value: Any,
parser: SQLParser<LogItem>
parser: SQLParser<LogItem>,
addIndex: Boolean = true
) {
val att: ParameterizedAttribute<Any> = ParameterizedAttribute(key, value.javaClass)
try {
addIndex(HashIndex.onAttribute(att))
} catch (e: IllegalStateException) {
// Maybe the index is already added
AppLog.d(e.message.orEmpty())
if (addIndex) {
try {
addIndex(HashIndex.onAttribute(att))
} catch (e: IllegalStateException) {
// Maybe the index is already added
AppLog.d(e.message.orEmpty())
}
}
parser.registerAttribute(att)
}
4 changes: 4 additions & 0 deletions src/main/kotlin/storage/Db.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ object Db {
return sessionInfoMap[sessionId]
}

fun updateSessionInfo(sessionId: String, sessionInfo: SessionInfo) {
sessionInfoMap[sessionId] = sessionInfo
}

fun getAllSessions() = diskDb.getAllNames().filter { it.startsWith(PREFIX) }.sortedBy { getSessionNumber(it) }

private fun getLastSessionNumber(): Int {
Expand Down
57 changes: 57 additions & 0 deletions src/main/kotlin/storage/SessionConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package storage

import models.SessionInfo

/**
* Operations for config related to session.
* These are stored in sessionInfo so that it is tied to session and will be deleted along with it.
*/
object SessionConfig {

private val currentSessionId
get() = Db.sessionId()

fun string(key: String, sessionId: String? = currentSessionId): String? = getConfig(key, sessionId)

fun boolDefaultOn(key: String, sessionId: String? = currentSessionId): Boolean {
return getConfig(key, sessionId)?.toBooleanStrictOrNull() ?: true
}

fun bool(key: String, sessionId: String? = currentSessionId, default: Boolean = false): Boolean {
return getConfig(key, sessionId)?.toBooleanStrictOrNull() ?: default
}

fun int(key: String, sessionId: String? = currentSessionId): Long? {
return getConfig(key, sessionId)?.toLongOrNull()
}

fun double(key: String, sessionId: String? = currentSessionId): Double? {
return getConfig(key, sessionId)?.toDoubleOrNull()
}

/**
* Updates config in db and returns updated [SessionInfo]
* If [sessionId] is null or blank or there is no config in db, this is a no-op and return null.
* If value is null, we will remove that key from db or put.
* This function creates a copy of session info and updates it
*/
fun set(key: String, value: Any?, sessionId: String? = currentSessionId): SessionInfo? {
if (sessionId.isNullOrBlank()) return null
val sInfo = Db.getSessionInfo(sessionId) ?: return null
val sInfoConfig = HashMap(sInfo.configs ?: emptyMap())
if (value == null) {
sInfoConfig.remove(key)
} else {
sInfoConfig[key] = value.toString()
}
val copy = sInfo.copy(configs = sInfoConfig)
Db.updateSessionInfo(sessionId, copy)
return copy
}

private fun getConfig(key: String, sessionId: String?): String? {
if (sessionId.isNullOrBlank()) return null
return Db.getSessionInfo(sessionId)?.configs?.get(key)
}

}
81 changes: 59 additions & 22 deletions src/main/kotlin/ui/components/ListItemInternalContent.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
package ui.components

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.selection.DisableSelection
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import models.ErrorContent
import models.InternalContent
import models.NoLogsContent
import org.apache.logging.log4j.core.util.StringBuilderWriter
import storage.Db
import storage.SessionConfig
import ui.CustomTheme
import java.io.PrintWriter
import utils.ConfigConstants

@Composable
fun ListItemInternalContent(internalContent: InternalContent?, modifier: Modifier = Modifier) {
Expand All @@ -39,37 +43,70 @@ private fun ListItemEmptyContent(noLogsContent: NoLogsContent, modifier: Modifie
noLogsContent.msg
}
Column(Modifier.padding(24.dp), horizontalAlignment = Alignment.CenterHorizontally) {
Image(painterResource("icons/empty_state.svg"), "Use start to log events",
Image(painterResource("icons/empty_state.svg"),
"Use start to log events",
Modifier.fillMaxWidth(0.5f).graphicsLayer { rotationY = 180f })
Spacer(Modifier.height(16.dp))
Text(
text, textAlign = TextAlign.Center,
style = CustomTheme.typography.headings.h5
text, textAlign = TextAlign.Center, style = CustomTheme.typography.headings.h5
)
}
}
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
private fun ListErrorContent(errorContent: ErrorContent, modifier: Modifier = Modifier) {
Card(modifier) {
SelectionContainer {
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
Text(errorContent.error, style = CustomTheme.typography.headings.h3)
Text("Exception:", style = CustomTheme.typography.headings.h6Medium)
val throwable = errorContent.throwable
if (throwable != null) {
val errorString = StringBuilderWriter()
val printWriter = PrintWriter(errorString)
throwable.printStackTrace(printWriter)
printWriter.flush()
Text(
errorString.toString(),
fontFamily = FontFamily.Monospace,
style = CustomTheme.typography.bodySmall
)
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
Text(errorContent.error, style = CustomTheme.typography.headings.h3)
Divider()
Column(
Modifier.fillMaxWidth().background(CustomTheme.colors.componentOutline, CustomTheme.shapes.large)
.padding(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text("Technical Exception:", style = CustomTheme.typography.headings.h6Medium)
val errorString = createExceptionString(errorContent.throwable)
SelectionContainer {
if (!errorString.isNullOrBlank()) {
Text(
errorString, fontFamily = FontFamily.Monospace, style = CustomTheme.typography.bodySmall
)
}
}
}
DisableSelection {
if (SessionConfig.boolDefaultOn(ConfigConstants.QUERY_INDEX)) {
val colors =
ButtonDefaults.textButtonColors(contentColor = CustomTheme.colors.alertColors.danger)
TextButton({
SessionConfig.set(ConfigConstants.QUERY_INDEX, false)
}, colors = colors) {
Text(CustomTheme.strings.turnOffFilterIndexText, textDecoration = TextDecoration.Underline)
}
}
}

}
}
}

@Preview
@Composable
fun ListError() {
val exception = Exception("Testing error")
ListErrorContent(ErrorContent("There is some error in this query", exception))
}

private fun createExceptionString(throwable: Throwable?): String? {
if (throwable == null) return null
val sb = StringBuilder()
sb.append(throwable.message)
val cause = throwable.cause?.message
if (!cause.isNullOrBlank()) {
sb.append(System.lineSeparator())
sb.append(cause)
}
return sb.toString()
}
Loading

0 comments on commit 5131c49

Please sign in to comment.