Skip to content

Commit

Permalink
update log object to be a dedicated logger to avoid config overwrit…
Browse files Browse the repository at this point in the history
…ing other kermit users, and add `setKotliteStdlibLogMinLevel` global function
  • Loading branch information
sunny-chung committed Apr 17, 2024
1 parent a781993 commit 06b0da7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions interpreter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Incorrect nullable resolution of extension properties
- `IntRange.joinToString` yields incorrect string value
- Function signature of `MutableMapValue`
- Logger is no longer a shared instance but a dedicated one

## [1.0.0] - 2024-04-08

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.sunnychung.lib.multiplatform.kotlite

import co.touchlab.kermit.LogWriter
import co.touchlab.kermit.Logger
import co.touchlab.kermit.MutableLoggerConfig
import co.touchlab.kermit.Severity
import co.touchlab.kermit.platformLogWriter

internal val log = Logger.apply {
setTag("kotlite")
setMinSeverity(Severity.Info)
}
internal val log = Logger(
config = object : MutableLoggerConfig {
override var logWriterList: List<LogWriter> = listOf(platformLogWriter())
override var minSeverity: Severity = Severity.Info
},
tag = "kotlite",
)

fun setKotliteLogMinLevel(severity: Severity) {
log.setMinSeverity(severity)
(log.config as MutableLoggerConfig).minSeverity = severity
}
8 changes: 7 additions & 1 deletion stdlib/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

Nothing yet.
### Added

- Global function `setKotliteStdlibLogMinLevel(severity: Severity)`

### Fixed

- Logger is no longer a shared instance but a dedicated one

## [1.0.0] - 2024-04-08

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package com.sunnychung.lib.multiplatform.kotlite.stdlib

import co.touchlab.kermit.LogWriter
import co.touchlab.kermit.Logger
import co.touchlab.kermit.MutableLoggerConfig
import co.touchlab.kermit.Severity
import co.touchlab.kermit.platformLogWriter

internal val log = Logger.apply {
setTag("kotlite-stdlib")
setMinSeverity(Severity.Info)
internal val log = Logger(
config = object : MutableLoggerConfig {
override var logWriterList: List<LogWriter> = listOf(platformLogWriter())
override var minSeverity: Severity = Severity.Info
},
tag = "kotlite-stdlib",
)

fun setKotliteStdlibLogMinLevel(severity: Severity) {
(log.config as MutableLoggerConfig).minSeverity = severity
}

0 comments on commit 06b0da7

Please sign in to comment.