All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.pixeloutlaw.kindling.Logger.kt Maven / Gradle / Ivy

package io.pixeloutlaw.kindling

/**
 * Analogous to an appender from Logback or log4j.
 */
public abstract class Logger {
    /**
     * Minimum [Log.Level] for this [Logger] implementation.
     */
    protected abstract val minimumLogLevel: Log.Level

    /**
     * Logs the given [message] at the given [level] if the level is allowed.
     */
    public fun log(
        level: Log.Level,
        tag: String = "",
        message: String? = null,
        throwable: Throwable? = null,
    ) {
        if (level.ordinal >= minimumLogLevel.ordinal) {
            print(LogRecord(level, tag, message, throwable))
        }
    }

    /**
     * Handles the given [logRecord].
     */
    protected abstract fun print(logRecord: LogRecord)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy