log
Inline logging functions for a flexible and efficient logging API.
The log
functions provide:
An optional level, defaulting to LogLevel.DEBUG.
An optional domain, which defaults to the calling context's class name.
A lambda message, evaluated only if the logging is enabled, ensuring no unnecessary computation.
By default, no logs will be generated unless a LogLogger
is explicitly installed. Use a logger such as LogcatStyleLogger or GlibLogLogger by calling Log.install to enable logging. The exact format and behavior of the logs depend on the logger implementation used.
Key Features
Lazy Evaluation: The log message is a lambda that is only executed if the logger deems the message loggable.
Automatic Domain Derivation: If domain is not provided, the calling class name is used as the default domain.
Simple API Surface: The API is minimal, with a single logging function and optional parameters for customization.
Overload of the log function that does not depend on this
. This is suitable for top-level functions or contexts without an available instance.
The logging configuration (e.g., format and behavior) depends on the currently installed Log. By default, no logs will be generated unless a logger is installed.
Parameters
The domain of the log, typically identifying the context (e.g., "MyComponent").
The level of the log message, defaulting to LogLevel.DEBUG.
A lambda producing the log message. Evaluated only if logging is enabled.