-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
158 changed files
with
1,475 additions
and
774 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
val pf4jVersion: String by project | ||
|
||
|
||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
implementation(kotlin("stdlib")) | ||
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl | ||
implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.0") | ||
implementation("org.apache.logging.log4j:log4j-api:2.17.0") | ||
implementation("org.apache.logging.log4j:log4j-core:2.17.0") | ||
|
||
compileOnly("org.pf4j:pf4j:${pf4jVersion}") | ||
// types parser for object to map conversion | ||
implementation("com.github.drapostolos:type-parser:0.7.0") | ||
implementation("com.google.code.gson:gson:2.8.9") | ||
// https://mvnrepository.com/artifact/com.google.guava/guava | ||
api("com.google.guava:guava:31.0.1-jre") | ||
testImplementation(platform("org.junit:junit-bom:5.8.2")) | ||
testImplementation("org.junit.jupiter:junit-jupiter") | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events("passed", "skipped", "failed") | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
api/src/main/kotlin/com/voxfinite/logvue/api/LogEventParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.voxfinite.logvue.api | ||
|
||
import com.voxfinite.logvue.api.models.LogCatMessage2 | ||
import com.voxfinite.logvue.api.models.LogItem | ||
import org.pf4j.ExtensionPoint | ||
|
||
/** | ||
* Plugin extension point | ||
* All plugins must extend with interface and annotate with @Extension | ||
*/ | ||
interface LogEventParser : ExtensionPoint { | ||
|
||
/** | ||
* Filters for tags | ||
*/ | ||
fun filters() : List<String> | ||
|
||
/** | ||
* Validate and return whether to process this message | ||
*/ | ||
fun validate(logCatMessage2: LogCatMessage2) : Boolean | ||
|
||
/** | ||
* Parse item which is validated before to [LogItem] | ||
* | ||
*/ | ||
fun parse(logCatMessage2: LogCatMessage2) : LogItem | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/models/InternalContent.kt → ...nite/logvue/api/models/InternalContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package models | ||
package com.voxfinite.logvue.api.models | ||
|
||
sealed interface InternalContent | ||
|
||
|
6 changes: 3 additions & 3 deletions
6
src/main/kotlin/models/ItemSource.kt → ...voxfinite/logvue/api/models/ItemSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package models | ||
package com.voxfinite.logvue.api.models | ||
|
||
import java.io.Serializable | ||
|
||
sealed class ItemSource(val type: String, val icon: String) : Serializable { | ||
abstract class ItemSource(val type: String, val icon: String) : Serializable { | ||
companion object { | ||
private const val serialVersionUID = 1L | ||
} | ||
} | ||
|
||
object SourceFA : ItemSource("Firebase", "icons/firebaseLogo.webp") | ||
object SourceFA : ItemSource("Firebase", "icons/firebaseLogo.webp") // TODO: Move to url | ||
object SourceInternalContent : ItemSource("Content", "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
src/main/kotlin/models/LogCatMessage2.kt → ...inite/logvue/api/models/LogCatMessage2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
api/src/main/kotlin/com/voxfinite/logvue/api/models/LogItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.voxfinite.logvue.api.models | ||
|
||
import com.voxfinite.logvue.api.utils.HashMapEntity | ||
import com.voxfinite.logvue.api.utils.hashMapEntityOf | ||
import java.io.Serializable | ||
import java.util.* | ||
|
||
/** | ||
* Base class for holding analytics data | ||
* Every plugin can extend [ItemSource] and add here along with event name and other details. | ||
* Do not add anything to [internalContent] | ||
*/ | ||
data class LogItem @JvmOverloads constructor( | ||
val source: ItemSource, | ||
val eventName: String, | ||
val properties: HashMapEntity<String, Any> = hashMapEntityOf(hashMapOf()), | ||
val localTime: Long = System.currentTimeMillis(), | ||
val internalContent: InternalContent? = null, | ||
) : Serializable { | ||
companion object { | ||
private const val serialVersionUID = 1L | ||
} | ||
|
||
private val id: String = buildKey() | ||
|
||
@Transient | ||
var isSelected: Boolean = false | ||
|
||
private fun buildKey() = "${iKey()}_$localTime" | ||
fun key() = id | ||
|
||
private fun iKey(): String { | ||
val k = "${source.type}_${eventName}_${properties.hashCode()}" | ||
return k + UUID.randomUUID().toString() | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
api/src/main/kotlin/com/voxfinite/logvue/api/models/LogLevel2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.voxfinite.logvue.api.models | ||
|
||
/** | ||
* Log Level enum. | ||
*/ | ||
enum class LogLevel2( | ||
/** | ||
* Returns the numerical value of the priority. | ||
*/ | ||
//$NON-NLS-1$ | ||
val priority: Int, | ||
/** | ||
* Returns a non translated string representing the LogLevel. | ||
*/ | ||
val stringValue: String, | ||
/** | ||
* Returns the letter identifying the priority of the [LogLevel2]. | ||
*/ | ||
val priorityLetter: Char | ||
) { | ||
VERBOSE(2, "verbose", 'V'), //$NON-NLS-1$ | ||
DEBUG(3, "debug", 'D'), //$NON-NLS-1$ | ||
INFO(4, "info", 'I'), //$NON-NLS-1$ | ||
WARN(5, "warn", 'W'), //$NON-NLS-1$ | ||
ERROR(6, "error", 'E'), //$NON-NLS-1$ | ||
ASSERT(7, "assert", 'A'); | ||
|
||
companion object { | ||
fun getByString(value: String): LogLevel2? { | ||
for (mode in values()) { | ||
if (mode.stringValue == value) { | ||
return mode | ||
} | ||
} | ||
return null | ||
} | ||
|
||
/** | ||
* Returns the [LogLevel2] enum matching the specified letter. | ||
* | ||
* @param letter the letter matching a `LogLevel` enum | ||
* @return a `LogLevel` object or `null` if no match were found. | ||
*/ | ||
fun getByLetter(letter: Char): LogLevel2? { | ||
for (mode in values()) { | ||
if (mode.priorityLetter == letter) { | ||
return mode | ||
} | ||
} | ||
return null | ||
} | ||
|
||
/** | ||
* Returns the [LogLevel2] enum matching the specified letter. | ||
* | ||
* | ||
* The letter is passed as a [String] argument, but only the first character | ||
* is used. | ||
* | ||
* @param letter the letter matching a `LogLevel` enum | ||
* @return a `LogLevel` object or `null` if no match were found. | ||
*/ | ||
fun getByLetterString(letter: String): LogLevel2? { | ||
return if (letter.isNotEmpty()) { | ||
getByLetter(letter[0]) | ||
} else null | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/utils/HashMapEntity.kt → ...xfinite/logvue/api/utils/HashMapEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package utils | ||
package com.voxfinite.logvue.api.utils | ||
|
||
import java.io.Serializable | ||
|
||
|
3 changes: 3 additions & 0 deletions
3
api/src/main/kotlin/com/voxfinite/logvue/api/utils/LogVueExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.voxfinite.logvue.api.utils | ||
|
||
fun <K, V> hashMapEntityOf(mapToWrap: MutableMap<K, V>): HashMapEntity<K, V> = HashMapEntity(mapToWrap) |
11 changes: 11 additions & 0 deletions
11
api/src/main/kotlin/com/voxfinite/logvue/api/utils/deserializers/EventDeserializers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.voxfinite.logvue.api.utils.deserializers | ||
|
||
import com.voxfinite.logvue.api.utils.deserializers.`object`.ObjectDeserializer | ||
import com.voxfinite.logvue.api.utils.deserializers.json.JsonDeserializer | ||
|
||
object EventDeserializers { | ||
|
||
fun fromObject(message: String?) = ObjectDeserializer.map(message) | ||
fun fromJson(message: String?) = JsonDeserializer.map(message) | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
api/src/main/kotlin/com/voxfinite/logvue/api/utils/deserializers/json/JsonDeserializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.voxfinite.logvue.api.utils.deserializers.json | ||
|
||
import com.google.gson.GsonBuilder | ||
import com.google.gson.JsonParseException | ||
import com.google.gson.JsonSyntaxException | ||
import com.google.gson.ToNumberPolicy | ||
import com.google.gson.reflect.TypeToken | ||
import com.voxfinite.logvue.api.utils.HashMapEntity | ||
import com.voxfinite.logvue.api.utils.hashMapEntityOf | ||
|
||
object JsonDeserializer { | ||
|
||
private val gson by lazy { | ||
val gsonBuilder = GsonBuilder().setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE) | ||
gsonBuilder.setPrettyPrinting() | ||
gsonBuilder.create() | ||
} | ||
|
||
fun createJsonString(src: Any): String { | ||
return gson.toJson(src) | ||
} | ||
|
||
fun map(message: String?): HashMapEntity<String, Any> { | ||
val type = object : TypeToken<HashMap<String, Any>>() {}.type | ||
val map = try { | ||
gson.fromJson<HashMap<String, Any>>(message, type) | ||
} catch (e: JsonParseException) { | ||
hashMapOf() | ||
} catch (e: JsonSyntaxException) { | ||
hashMapOf() | ||
} | ||
return hashMapEntityOf(map) | ||
} | ||
|
||
} |
Oops, something went wrong.