log
Inline logging functions for a flexible and efficient logging API.
The log
functions provide:
An optional priority, defaulting to LogPriority.DEBUG.
An optional logDomain, 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 LogLogger.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 logDomain 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 LogLogger. 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 priority of the log message, defaulting to LogPriority.DEBUG.
A lambda producing the log message. Evaluated only if logging is enabled.