GLibLogWriter

class GLibLogWriter(minLevel: LogLevel = LogLevel.DEBUG) : LogWriter

A LogWriter implementation that uses GLib's g_log for logging.

This integrates with GLib's logging system and supports GLib log levels.

Key Features

  • Automatically enables DEBUG and INFO log levels if the minimum level is set below MESSAGE.

  • Logs messages directly using g_log.

  • Honors GLib's G_MESSAGES_DEBUG environment variable for enabling lower-level log messages.

Installation Convenience Methods

For convenience, companion methods allow adding this writer conditionally:

  • Use install to install for both debug and release builds.

  • Use installOnDebuggableApp for debug builds.

  • Use installOnReleaseApp for release builds.

Parameters

minLevel

The minimum log level to log. Default is LogLevel.DEBUG. Setting it below LogPriority.MESSAGE will enable DEBUG and INFO levels.

Constructors

Link copied to clipboard
constructor(minLevel: LogLevel = LogLevel.DEBUG)

Functions

Link copied to clipboard
open fun close()
Link copied to clipboard
open override fun isLoggable(level: LogLevel): Boolean

Determines if this writer is willing to handle messages with the given level.

Link copied to clipboard
open override fun write(level: LogLevel, domain: String, message: String)

Writes the log message. If isLoggable returned false, this method should ideally never be called, but if it is, it should no-op.