File tree Expand file tree Collapse file tree
androidMain/kotlin/io/github/oshai/kotlinlogging
darwinMain/kotlin/io/github/oshai/kotlinlogging
jsMain/kotlin/io/github/oshai/kotlinlogging
jvmMain/kotlin/io/github/oshai/kotlinlogging
nativeMain/kotlin/io/github/oshai/kotlinlogging
wasmJsMain/kotlin/io/github/oshai/kotlinlogging Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,7 +36,10 @@ public actual object KotlinLoggingConfiguration {
3636
3737 @Volatile public actual var loggerFactory: KLoggerFactory = detectLogger()
3838
39- public actual var logStartupMessage: Boolean = true
39+ public actual var logStartupMessage: Boolean =
40+ System .getProperty(" kotlin-logging.logStartupMessage" )?.toBoolean()
41+ ? : System .getenv(" KOTLIN_LOGGING_STARTUP_MESSAGE" )?.toBoolean()
42+ ? : true
4043
4144 private fun detectLogger (): KLoggerFactory {
4245 if (System .getProperty(" kotlin-logging-to-android-native" ) != null ) {
Original file line number Diff line number Diff line change 11package io.github.oshai.kotlinlogging
22
33import kotlin.concurrent.AtomicReference
4+ import platform.posix.getenv
5+ import kotlinx.cinterop.toKString
6+ import kotlinx.cinterop.ExperimentalForeignApi
7+
8+ @OptIn(ExperimentalForeignApi ::class )
9+ private fun getEnv (name : String ): String? {
10+ return getenv(name)?.toKString()
11+ }
12+
413
514public actual object KotlinLoggingConfiguration {
615 // Existing Darwin-specific properties
716 public var subsystem: AtomicReference <String ?> = AtomicReference (null )
817 public var category: AtomicReference <String ?> = AtomicReference (null )
918
10- private val _logStartupMessage = AtomicReference (true )
19+ private val _logStartupMessage = AtomicReference (getEnv( " KOTLIN_LOGGING_STARTUP_MESSAGE " )?.toBoolean() ? : true )
1120 public actual var logStartupMessage: Boolean
1221 get() = _logStartupMessage .value
1322 set(value) {
Original file line number Diff line number Diff line change 11package io.github.oshai.kotlinlogging
22
3+ private fun resolveStartupMessageDefault (): Boolean {
4+ try {
5+ val disabledInWindow = js(" typeof window !== 'undefined' && (window.KOTLIN_LOGGING_STARTUP_MESSAGE === 'false' || window.KOTLIN_LOGGING_STARTUP_MESSAGE === false)" ) as Boolean
6+ if (disabledInWindow) {
7+ return false
8+ }
9+
10+ val disabledInEnv = js(" typeof process !== 'undefined' && process.env && (process.env.KOTLIN_LOGGING_STARTUP_MESSAGE === 'false' || process.env.KOTLIN_LOGGING_STARTUP_MESSAGE === false)" ) as Boolean
11+ if (disabledInEnv) {
12+ return false
13+ }
14+
15+ return true
16+ } catch (e: Throwable ) {
17+ return true
18+ }
19+ }
20+
321public actual object KotlinLoggingConfiguration {
4- public actual var logStartupMessage: Boolean = true
22+ public actual var logStartupMessage: Boolean = resolveStartupMessageDefault()
523
624 public actual val direct: DirectLoggingConfiguration =
725 object : DirectLoggingConfiguration {
Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ public actual object KotlinLoggingConfiguration {
1111 */
1212 @Volatile public actual var loggerFactory: KLoggerFactory = detectLogger()
1313
14- public actual var logStartupMessage: Boolean = true
14+ public actual var logStartupMessage: Boolean =
15+ System .getProperty(" kotlin-logging.logStartupMessage" )?.toBoolean()
16+ ? : System .getenv(" KOTLIN_LOGGING_STARTUP_MESSAGE" )?.toBoolean()
17+ ? : true
1518
1619 public actual val direct: DirectLoggingConfiguration =
1720 object : DirectLoggingConfiguration {
Original file line number Diff line number Diff line change 11package io.github.oshai.kotlinlogging
22
33import kotlin.concurrent.AtomicReference
4+ import platform.posix.getenv
5+ import kotlinx.cinterop.toKString
6+ import kotlinx.cinterop.ExperimentalForeignApi
7+
8+ @OptIn(ExperimentalForeignApi ::class )
9+ private fun getEnv (name : String ): String? {
10+ return getenv(name)?.toKString()
11+ }
12+
413
514public actual object KotlinLoggingConfiguration {
615 public actual val direct: DirectLoggingConfiguration =
@@ -31,7 +40,7 @@ public actual object KotlinLoggingConfiguration {
3140 }
3241 }
3342
34- private val _logStartupMessage = AtomicReference (true )
43+ private val _logStartupMessage = AtomicReference (getEnv( " KOTLIN_LOGGING_STARTUP_MESSAGE " )?.toBoolean() ? : true )
3544 public actual var logStartupMessage: Boolean
3645 get() = _logStartupMessage .value
3746 set(value) {
Original file line number Diff line number Diff line change 11package io.github.oshai.kotlinlogging
22
3+ private fun resolveStartupMessageDefault (): Boolean {
4+ try {
5+ val disabledInWindow = js(" typeof window !== 'undefined' && (window.KOTLIN_LOGGING_STARTUP_MESSAGE === 'false' || window.KOTLIN_LOGGING_STARTUP_MESSAGE === false)" ) as Boolean
6+ if (disabledInWindow) {
7+ return false
8+ }
9+
10+ val disabledInEnv = js(" typeof process !== 'undefined' && process.env && (process.env.KOTLIN_LOGGING_STARTUP_MESSAGE === 'false' || process.env.KOTLIN_LOGGING_STARTUP_MESSAGE === false)" ) as Boolean
11+ if (disabledInEnv) {
12+ return false
13+ }
14+
15+ return true
16+ } catch (e: Throwable ) {
17+ return true
18+ }
19+ }
20+
321public actual object KotlinLoggingConfiguration {
422 public actual val direct: DirectLoggingConfiguration =
523 object : DirectLoggingConfiguration {
@@ -36,5 +54,5 @@ public actual object KotlinLoggingConfiguration {
3654
3755 public actual var loggerFactory: KLoggerFactory = DirectLoggerFactory
3856
39- public actual var logStartupMessage: Boolean = true
57+ public actual var logStartupMessage: Boolean = resolveStartupMessageDefault()
4058}
You can’t perform that action at this time.
0 commit comments