Logger class abstract

Logger serves as a flexible and configurable logging utility designed to support various logging levels and formats. It follows the Singleton pattern to ensure a consistent logging mechanism throughout the application. This class allows for detailed logging control, including setting minimum log levels, customizing log message formats, and specifying log output destinations through adapters.

To use the logger:

Logger.I.info(message: 'Application initialization complete.');

To customize the logger, consider using LoggerBuilder before accessing Logger.I for the first time.

Constructors

Logger.new()

Properties

adapter LoggerAdapter
The current LoggerAdapter in use, which directs the formatted log messages to a specific output, such as console, file, or network. Changing the adapter allows for flexible redirection of log output.
getter/setter pair
formatter LogFormatter
The LogFormatter responsible for converting log messages and their associated data into a specific format. Custom formatters can be set to modify log message appearance.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
minimumLogLevel LogLevel?
The minimum level of log messages that will be processed. Messages below this level will be ignored. This allows for runtime control over logging verbosity.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

debug({required String message, StackTrace? stackTrace}) → void
Logs a message at the debug level, a notch above trace, useful for general debugging and development information that's less verbose than trace.
error({required String message, required String error, StackTrace? stackTrace}) → void
Logs a message at the error level, indicating an issue that has occurred, but the application can still continue running. Error logs are critical for identifying issues that need attention.
fatal({required String message, required String error, StackTrace? stackTrace}) → void
Logs a message at the fatal level, used for severe errors that will likely cause the application to terminate. Fatal logs represent the most critical level of logging.
info({required String message, StackTrace? stackTrace}) → void
Logs a message at the info level, intended for informational messages that highlight the application's progress and significant state changes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldLog(LogLevel level) bool
Determines if a log message of a given level should be logged, based on the current minimumLogLevel. This method facilitates log level filtering.
toString() String
A string representation of this object.
inherited
trace({required String message, StackTrace? stackTrace}) → void
Logs a message at the trace level, which is the most verbose level used for detailed debugging information. Trace logs are ideal for understanding the flow and state of the application.
warning({required String message, StackTrace? stackTrace}) → void
Logs a message at the warning level, suitable for situations that are not errors but may warrant caution or further investigation.

Operators

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

Static Properties

I Logger
A convenient alias for instance, providing shorthand access to the singleton Logger.
no setter
instance Logger
Provides a global access point to the singleton instance of Logger. If not previously instantiated, it will initialize with default settings. Prefer using Logger.I for concise access.
no setter