-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #594 from hexagonkt/develop
Develop
- Loading branch information
Showing
35 changed files
with
251 additions
and
73 deletions.
There are no files selected for viewing
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
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: 2 additions & 3 deletions
5
core/src/main/kotlin/com/hexagonkt/core/logging/LoggingManager.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
14 changes: 14 additions & 0 deletions
14
core/src/main/kotlin/com/hexagonkt/core/logging/PrintLogger.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,14 @@ | ||
package com.hexagonkt.core.logging | ||
|
||
import com.hexagonkt.core.toText | ||
|
||
data class PrintLogger(val name: String) : LoggerPort { | ||
|
||
override fun <E : Throwable> log(level: LoggingLevel, exception: E, message: (E) -> Any?) { | ||
println("$level - ${message(exception)}:\n${exception.toText()}") | ||
} | ||
|
||
override fun log(level: LoggingLevel, message: () -> Any?) { | ||
println("$level - ${message()}") | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
core/src/main/kotlin/com/hexagonkt/core/logging/PrintLoggingAdapter.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,34 @@ | ||
package com.hexagonkt.core.logging | ||
|
||
import com.hexagonkt.core.logging.LoggingLevel.INFO | ||
import com.hexagonkt.core.require | ||
|
||
class PrintLoggingAdapter(defaultLevel: LoggingLevel = INFO) : LoggingPort { | ||
|
||
private val loggerLevels: MutableMap<String, LoggingLevel> = mutableMapOf("" to defaultLevel) | ||
|
||
override fun createLogger(name: String): LoggerPort = | ||
PrintLogger(name) | ||
|
||
override fun setLoggerLevel(name: String, level: LoggingLevel) { | ||
loggerLevels[name] = level | ||
} | ||
|
||
override fun isLoggerLevelEnabled(name: String, level: LoggingLevel): Boolean = | ||
findLoggingLevel(name).ordinal <= level.ordinal | ||
|
||
private fun findLoggingLevel(name: String): LoggingLevel { | ||
var path = name | ||
|
||
do { | ||
val loggingLevel = loggerLevels[path] | ||
if (loggingLevel != null) | ||
return loggingLevel | ||
|
||
path = path.substringBeforeLast('.') | ||
} | ||
while (path.contains('.')) | ||
|
||
return loggerLevels.require("") | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.