Implement "debug" level for logging (#107)

This commit is contained in:
Artyom 2023-01-10 14:02:39 +03:00 committed by GitHub
parent a85e655aba
commit 20f07a4a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,5 @@
package ru.touchin.logger.dto
enum class LogLevel {
Trace, Info, Error
Trace, Debug, Info, Error
}

View File

@ -31,6 +31,14 @@ abstract class AbstractLog(clazz: Class<*>) : Log<LogData> {
}
}
override fun debug() {
if (logger.isDebugEnabled) {
val logMessage = getMessage()
logger.debug(logMessage.message, logMessage.error)
}
}
override fun info() {
if (logger.isInfoEnabled) {
val logMessage = getMessage()
@ -58,6 +66,7 @@ abstract class AbstractLog(clazz: Class<*>) : Log<LogData> {
override fun isEnabled(level: LogLevel): Boolean {
return when(level) {
LogLevel.Trace -> logger.isTraceEnabled
LogLevel.Debug -> logger.isDebugEnabled
LogLevel.Info -> logger.isInfoEnabled
LogLevel.Error -> logger.isErrorEnabled
}

View File

@ -6,6 +6,7 @@ interface Log<T> {
var logData: T
fun trace()
fun debug()
fun info()
fun error()