mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-05-18 06:24:12 +02:00
feat(connector): add logging with KotlinLogger and reload4j
This commit is contained in:
parent
9482ba3d97
commit
62e9267775
@ -11,6 +11,8 @@ val voyagerVersion = "1.0.0"
|
||||
val kotlinxVersion = "1.8.0"
|
||||
val koinVersion = "3.5.3"
|
||||
val kodeinVersion = "7.21.2"
|
||||
val kotlinLogging = "5.1.0"
|
||||
val sl4jVersion = "2.0.13"
|
||||
|
||||
// Testing Versions
|
||||
val jupyterVersion = "5.10.1"
|
||||
@ -62,6 +64,11 @@ kotlin {
|
||||
implementation("cafe.adriel.voyager:voyager-koin:$voyagerVersion")
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:$kotlinxVersion")
|
||||
|
||||
// Kotlin Logging
|
||||
implementation("io.github.oshai:kotlin-logging-jvm:$kotlinLogging")
|
||||
implementation("org.slf4j:slf4j-api:$sl4jVersion")
|
||||
implementation("org.slf4j:slf4j-reload4j:$sl4jVersion")
|
||||
}
|
||||
|
||||
// Testing
|
||||
|
@ -0,0 +1,9 @@
|
||||
log4j.rootLogger=DEBUG, A1
|
||||
log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Print the date in ISO 8601 format
|
||||
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
||||
|
||||
# Print only messages of level WARN or above in the package com.foo.
|
||||
log4j.logger.com.foo=WARN
|
@ -4,12 +4,15 @@ import cafe.adriel.voyager.core.model.StateScreenModel
|
||||
import cafe.adriel.voyager.core.model.screenModelScope
|
||||
import io.anthonyberg.connector.shared.ProjectTransaction
|
||||
import io.anthonyberg.connector.shared.entity.Project
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ProjectsScreenModel (
|
||||
private val db: ProjectTransaction
|
||||
) : StateScreenModel<ProjectState>(ProjectState.Loading) {
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
fun projectExists() {
|
||||
screenModelScope.launch {
|
||||
mutableState.value = ProjectState.Loading
|
||||
@ -27,7 +30,7 @@ class ProjectsScreenModel (
|
||||
|
||||
private fun getProjects(): List<Project> {
|
||||
val projects = db.getProjects()
|
||||
println(projects)
|
||||
logger.debug { "Loaded projects from database: $projects" }
|
||||
|
||||
return projects
|
||||
}
|
||||
|
@ -18,11 +18,13 @@ import androidx.compose.ui.unit.dp
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
import cafe.adriel.voyager.koin.getScreenModel
|
||||
import io.anthonyberg.connector.shared.entity.Action
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
|
||||
class TestRun (
|
||||
private val actions: List<Action>
|
||||
) : Screen {
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
private var tested = mutableStateListOf<Boolean>()
|
||||
|
||||
@Composable
|
||||
@ -40,30 +42,35 @@ class TestRun (
|
||||
}
|
||||
|
||||
when (val s = state) {
|
||||
is TestState.Init -> println("Loading Simulator Tests")
|
||||
is TestState.Init -> logger.info { "Loading Simulator Tests" }
|
||||
is TestState.NoSimulator -> {
|
||||
running = false
|
||||
logger.warn { "Could not connect to the simulator" }
|
||||
Text("Could not connect to the simulator!")
|
||||
return
|
||||
}
|
||||
is TestState.Ready -> {
|
||||
println("Loaded Simulator Tests")
|
||||
logger.info { "Loaded Simulator Tests" }
|
||||
|
||||
screenModel.runAction(actions[step])
|
||||
}
|
||||
is TestState.Running -> println("Running Action: ${s.step}")
|
||||
is TestState.Running -> logger.info { "Running Action: ${s.step}" }
|
||||
is TestState.Complete -> {
|
||||
logger.info { "Completed test for action: ${s.step}" }
|
||||
tested.add(s.pass)
|
||||
|
||||
step += 1
|
||||
if (step == actions.size) {
|
||||
logger.info { "Completed all tests" }
|
||||
screenModel.end()
|
||||
} else {
|
||||
screenModel.runAction(actions[step])
|
||||
}
|
||||
}
|
||||
is TestState.Idle -> running = false
|
||||
is TestState.Error -> return Text("An error occurred!")
|
||||
is TestState.Error -> {
|
||||
logger.error { "An error occurred!" }
|
||||
return Text("An error occurred!")
|
||||
}
|
||||
}
|
||||
|
||||
Column(
|
||||
|
@ -9,7 +9,7 @@ val coroutinesVersion = "1.8.0"
|
||||
val ktorVersion = "2.3.9"
|
||||
val sqlDelightVersion = "2.0.2"
|
||||
val dateTimeVersion = "0.5.0"
|
||||
val sl4jVersion = "2.0.12"
|
||||
val sl4jVersion = "2.0.13"
|
||||
val vdmjVersion = "4.5.0"
|
||||
|
||||
// Testing Dependencies
|
||||
|
Loading…
x
Reference in New Issue
Block a user