English | 简体中文

api-docs / org.ktorm.logging / Logger

Logger

interface Logger (source code)

A simple logging interface abstracting third-party logging frameworks.

The logging levels used by Ktorm is defined in the enum class LogLevel in a certain order. While TRACE is
the least serious and ERROR is the most serious. The mapping of these log levels to the concepts used by the
underlying logging system is implementation dependent. The implementation should ensure, though, that this ordering
behaves are expected.

By default, Ktorm auto-detects a logging implementation from the classpath while creating Database instances.
If you want to output logs using a specific logging framework, you can choose an adapter implementation of this
interface and explicitly set the Database.logger property.

Ktorm prints logs at different levels:

  • Generated SQLs and their execution arguments are printed at DEBUG level, so if you want to see the SQLs, you
    should configure your logging framework to enable the DEBUG level.
  • Detailed data of every returned entity object are printed at TRACE level, if you want to see them, you should configure your framework to enable TRACE.
  • Besides, start-up messages are printed at INFO level, warnings are printed at WARN level, and exceptions are printed at ERROR level. These levels should be enabled by default.

Functions

NameSummary

debug

abstract fun debug(msg: String, e: Throwable? = null): Unit

Log a message at the DEBUG level.

error

abstract fun error(msg: String, e: Throwable? = null): Unit

Log a message at the ERROR level.

info

abstract fun info(msg: String, e: Throwable? = null): Unit

Log a message at the INFO level.

isDebugEnabled

abstract fun isDebugEnabled(): Boolean

Check if the logger instance enabled for the DEBUG level.

isErrorEnabled

abstract fun isErrorEnabled(): Boolean

Check if the logger instance enabled for the ERROR level.

isInfoEnabled

abstract fun isInfoEnabled(): Boolean

Check if the logger instance enabled for the INFO level.

isTraceEnabled

abstract fun isTraceEnabled(): Boolean

Check if the logger instance enabled for the TRACE level.

isWarnEnabled

abstract fun isWarnEnabled(): Boolean

Check if the logger instance enabled for the WARN level.

trace

abstract fun trace(msg: String, e: Throwable? = null): Unit

Log a message at the TRACE level.

warn

abstract fun warn(msg: String, e: Throwable? = null): Unit

Log a message at the WARN level.

Extension Functions

NameSummary

eq

infix fun <T : Any> T.eq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Equal operator, translated to = in SQL.

neq

infix fun <T : Any> T.neq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Not-equal operator, translated to <> in SQL.

notEq

infix fun <T : Any> T.notEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Not-equal operator, translated to <> in SQL.

Inheritors

NameSummary

AndroidLoggerAdapter

class AndroidLoggerAdapter : Logger

Adapter Logger implementation integrating android.util.Log with Ktorm.

CommonsLoggerAdapter

class CommonsLoggerAdapter : Logger

Adapter Logger implementation integrating Apache Commons Logging with Ktorm.

ConsoleLogger

class ConsoleLogger : Logger

Simple Logger implementation printing logs to the console. While messages at WARN or ERROR levels are printed to System.err, others are printed to System.out.

JdkLoggerAdapter

class JdkLoggerAdapter : Logger

Adapter Logger implementation integrating java.util.logging with Ktorm.

NoOpLogger

object NoOpLogger : Logger

Logger implementation that performs no operations.

Slf4jLoggerAdapter

class Slf4jLoggerAdapter : Logger

Adapter Logger implementation integrating Slf4j with Ktorm.