LoggerBuilder class

LoggerBuilder provides a fluent interface for constructing and configuring a Logger instance. It allows for setting the minimum log level, choosing a specific log adapter, and defining a custom log message formatter.

This builder ensures that the logger is configured to suit specific logging requirements before it is used throughout the application. Once the builder configures a Logger, the same configuration and instance can be accessed globally via Logger.I.

Example usage:

LoggerBuilder()
  .withLogLevel(LogLevel.debug)
  .withAdapter(CustomLoggerAdapter())
  .withFormatter(CustomLogFormatter())
  .build();

Logger.I.debug(message: 'Logger configured with custom settings.');

Constructors

LoggerBuilder.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build() Logger
Finalizes the configuration of the Logger and ensures that it is ready for use throughout the application. This method should be called once, typically during application initialization, before any log messages are recorded.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
withAdapter(LoggerAdapter adapter) LoggerBuilder
Specifies the LoggerAdapter to use for outputting log messages. Different adapters can direct log output to various destinations such as the console, files, or external logging services.
withFormatter(LogFormatter formatter) LoggerBuilder
Sets the LogFormatter for formatting log messages. Custom formatters can provide different formats for log messages, such as including timestamps, log levels, or other contextual information.
withLogLevel(LogLevel logLevel) LoggerBuilder
Sets the minimum LogLevel for the logger. Logs below this level will not be processed or output. This allows for control over the verbosity of log messages that are recorded or displayed.

Operators

operator ==(Object other) bool
The equality operator.
inherited