Log

object Log

Log acts as a global, thread-safe manager for log writers.

By default, no writers are installed, so no logs will appear. To enable logging, add one or more LogWriters using install. All logging calls will be delegated to the installed writers.

You can remove a writer using uninstall, and multiple writers can be active at the same time.

This approach solves:

  • Having multiple loggers: Just install multiple writers.

  • No duplication of installation logic: Add or remove writers through Log.

  • Easy extensibility: Implement your own LogWriter to customize messages or formatting.

Properties

Link copied to clipboard

A user-configurable default domain for logs. If set, any log call with domain = null will use this value instead of deriving it from the caller.

Link copied to clipboard

Determines the default minimum level for release builds based on whether GLib's debug logging is enabled.

Functions

Link copied to clipboard
fun install(writer: LogWriter)

Installs a new writer to the global logging system.

Link copied to clipboard
fun Log.installConsoleLogWriter(minLevelDebug: LogLevel = LogLevel.DEBUG, minLevelRelease: LogLevel = defaultReleaseLogLevel, time: Boolean = true)

Installs this writer for both debug and release builds.

Link copied to clipboard
fun Log.installConsoleLogWriterForDebugBuilds(minLevel: LogLevel = LogLevel.DEBUG, time: Boolean = true)

Installs this writer for debug builds if the application is debuggable.

Link copied to clipboard
fun Log.installConsoleLogWriterForReleaseBuilds(minLevel: LogLevel = defaultReleaseLogLevel, time: Boolean = true)

Installs this writer for release builds if the application is not debuggable.

Link copied to clipboard
fun Log.installGLibLogWriter(minLevelDebug: LogLevel = LogLevel.DEBUG, minLevelRelease: LogLevel = defaultReleaseLogLevel)

Installs this writer for both debug and release builds.

Link copied to clipboard
fun Log.installGLibLogWriterForDebugBuilds(minPriority: LogLevel = LogLevel.DEBUG)

Installs this writer for debug builds if the application is debuggable.

Link copied to clipboard
fun Log.installGLibLogWriterForReleaseBuilds(minPriority: LogLevel = defaultReleaseLogLevel)

Installs this writer for release builds if the application is not debuggable.

Link copied to clipboard

Checks if GLib debug logging is enabled.

Link copied to clipboard
fun uninstall(writer: LogWriter)

Uninstalls an installed writer.

Link copied to clipboard

Uninstalls all currently installed writers.