Skip to content

Commit bca0591

Browse files
committed
added a fix for issue #17
implemented all log methods in location aware logger
1 parent 01ce305 commit bca0591

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

src/main/kotlin/mu/internal/LocationAwareKLogger.kt

+69
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,73 @@ internal class LocationAwareKLogger(private val jLogger: LocationAwareLogger) :
474474
LocationAwareLogger.ERROR_INT, msg, null, t)
475475
}
476476

477+
/**
478+
* Lazy add a log message if isTraceEnabled is true
479+
*/
480+
override fun trace(msg: () -> Any?) {
481+
if (isTraceEnabled) trace(msg.invoke().toString())
482+
}
483+
484+
/**
485+
* Lazy add a log message if isDebugEnabled is true
486+
*/
487+
override fun debug(msg: () -> Any?) {
488+
if (isDebugEnabled) debug(msg.invoke().toString())
489+
}
490+
491+
/**
492+
* Lazy add a log message if isInfoEnabled is true
493+
*/
494+
override fun info(msg: () -> Any?) {
495+
if (isInfoEnabled) info(msg.invoke().toString())
496+
}
497+
498+
/**
499+
* Lazy add a log message if isWarnEnabled is true
500+
*/
501+
override fun warn(msg: () -> Any?) {
502+
if (isWarnEnabled) warn(msg.invoke().toString())
503+
}
504+
505+
/**
506+
* Lazy add a log message if isErrorEnabled is true
507+
*/
508+
override fun error(msg: () -> Any?) {
509+
if (isErrorEnabled) error(msg.invoke().toString())
510+
}
511+
512+
/**
513+
* Lazy add a log message with throwable payload if isTraceEnabled is true
514+
*/
515+
override fun trace(t: Throwable, msg: () -> Any?) {
516+
if (isTraceEnabled) trace(msg.invoke().toString(), t)
517+
}
518+
519+
/**
520+
* Lazy add a log message with throwable payload if isDebugEnabled is true
521+
*/
522+
override fun debug(t: Throwable, msg: () -> Any?) {
523+
if (isDebugEnabled) debug(msg.invoke().toString(), t)
524+
}
525+
526+
/**
527+
* Lazy add a log message with throwable payload if isInfoEnabled is true
528+
*/
529+
override fun info(t: Throwable, msg: () -> Any?) {
530+
if (isInfoEnabled) info(msg.invoke().toString(), t)
531+
}
532+
533+
/**
534+
* Lazy add a log message with throwable payload if isWarnEnabled is true
535+
*/
536+
override fun warn(t: Throwable, msg: () -> Any?) {
537+
if (isWarnEnabled) warn(msg.invoke().toString(), t)
538+
}
539+
540+
/**
541+
* Lazy add a log message with throwable payload if isErrorEnabled is true
542+
*/
543+
override fun error(t: Throwable, msg: () -> Any?) {
544+
if (isErrorEnabled) error(msg.invoke().toString(), t)
545+
}
477546
}

0 commit comments

Comments
 (0)