LoggerScope

interface LoggerScope : Logger

Wrapper for Logger which prepends each logged message with the scope.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val identity: Logger

The wrapped Logger.

Link copied to clipboard
abstract val scope: String

Description of the scope, usually a class name or a custom name.

Functions

Link copied to clipboard
fun Logger.debug(message: String, throwable: Throwable? = null)

Calls Logger.log message with Debug level.

Link copied to clipboard
inline fun <T> Logger.duration(body: () -> T): T

Measures the duration it takes to invoke the body. Logs with Verbose level message Started before the invocation and Finished took XYZms after completion.

Link copied to clipboard
fun Logger.error(message: String, throwable: Throwable? = null)

Calls Logger.log message with Error level.

Link copied to clipboard
fun Logger.info(message: String, throwable: Throwable? = null)

Calls Logger.log message with Info level.

Link copied to clipboard
abstract fun log(level: Level, message: String, throwable: Throwable? = null)

Uses level to determine whether it should be passed to the underlying implementation. Implementations are free to use whichever level they like.

Link copied to clipboard
inline fun <T> LoggerScope.scope(name: String, body: LoggerScope.() -> T): T

Creates temporary sub-scope of current LoggerScope with custom name post-fixed to the new scope. The sub-scope is discarded once the body invocation is finished.

Link copied to clipboard
inline fun <T> LoggerScope.timedScope(name: String, body: () -> T): T

Measures the duration of a scope.

Link copied to clipboard
fun Logger.verbose(message: String, throwable: Throwable? = null)

Calls Logger.log message with Verbose level.

Link copied to clipboard
fun Logger.warning(message: String, throwable: Throwable? = null)

Calls Logger.log message with Warning level.