Log class

A utility class for managing logging operations.

The Log class provides static methods to log messages with various levels (e.g., info, error, debug), configure loggers, and handle critical mode operations. It interacts with LoggerManager for standard logging and CriticalStorage for critical mode storage.

Example:

Log.info("App", "Application started");
Log.createLogger("MyLogger", categories: "App,Debug");

Constructors

Log()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

criticalStorage CriticalStorage?
Storage for log messages when in critical mode.
getter/setter pair
isCriticalMode bool
Indicates whether the logger is in critical mode.
getter/setter pair
loggerManager LoggerManager
The manager responsible for handling loggers and their configurations.
getter/setter pair

Static Methods

clearMessageList({String logger = 'Main'}) LogError
Clears the message list for the specified logger.
closeLogger({String logger = 'Main'}) LogError
Closes the specified logger.
connectViewer({required String address, void onConnect(LogError)?, void onReceive(dynamic)?, void onError(String)?}) LogError
createLogger(String logId, {String? categories, bool enableConsoleOutput = true}) LogError
Creates a new logger with the specified configuration.
critical(String category, String message, {String? environment}) LogError
Logs a critical message.
debug(String category, String message, {String? environment}) LogError
Logs a debug message.
disableAllOutputs({String logger = 'Main'}) LogError
Disables All output for the specified logger.
disableConsoleOutput({String logger = 'Main'}) LogError
Disables console output for the specified logger.
disableFileOutput({String logger = 'Main'}) LogError
Disables file output for the specified logger.
disableProcessOutput({String logger = 'Main'}) LogError
Disables process output for the specified logger.
disableStorageOutput({String logger = 'Main'}) LogError
Disables storage output for the specified logger.
disconnectViewer() LogError
enableConsoleOutput({String logger = 'Main', bool exclusive = false}) LogError
Enables console output for the specified logger.
enableFileOutput({String logger = 'Main', bool exclusive = false, String? logFileName, bool append = false, bool flush = false, SaveFormat format = SaveFormat.text}) LogError
Enables file output for the specified logger.
enableProcessOutput({String logger = 'Main', bool exclusive = false, dynamic onLogMessage(LogMessage message)?}) LogError
Enables process output for the specified logger.
enableStorageOutput({String logger = 'Main', bool exclusive = false}) LogError
Enables storage output for the specified logger.
enterCriticalMode({int size = 10, bool growable = true}) LogError
Enters critical mode, enabling message storage.
error(String category, String message, {String? environment}) LogError
Logs an error message.
exitCriticalMode() LogError
Exits critical mode and processes stored messages.
fatal(String category, String message, {String? environment}) LogError
Logs a fatal message.
getAllCategories({String logger = 'Main'}) List<String>
Retrieves all categories for the specified logger.
getMessageList({String logger = 'Main'}) List<LogMessage>
Retrieves the list of stored log messages for the specified logger.
getOutputFileActive({String logger = 'Main'}) LoggerFileBase?
Retrieves the active file output for the specified logger.
getOutputsEnabled({String logger = 'Main'}) List<String>
Retrieves the list of enabled outputs for the specified logger.
getStatusViewer() String
info(String category, String message, {String? environment}) LogError
Logs an informational message.
installCustomLogger(LoggerBase logger) LogError
Installs a custom logger implementation.
installService({String logger = 'Main', required LogService service}) LogError
loadContext(String path, {Map<String, dynamic Function(LogMessage message)>? processMap}) LogError
Loads a YAML file to initialize the different loggers.
log(String category, String message, {String? environment, Object level = 'info'}) LogError
Logs a message with the specified category and level.
printMessageList({String logger = 'Main', bool clear = false, String? tag}) LogError
Prints the message list to the console.
processLogMessage(LogMessage message) LogError
Processes a LogMessage and returns the result.
processMessageList({String logger = 'Main', dynamic onLogMessage(LogMessage message)?, bool clear = false}) LogError
Processes the message list with the configured outputs.
removeService({String logger = 'Main'}) LogError
saveMessageList({required String logFileName, String logger = 'Main', bool append = false, bool flush = false, SaveFormat format = SaveFormat.text, bool clear = false}) LogError
Saves the message list to a file.
setCategories(String categories, {String logger = 'Main', bool clear = false}) LogError
Sets up categories for the specified logger.
setDecoration({String logger = 'Main', bool timeStamp = false, bool timeLine = false, bool loggerID = false, bool category = false, bool environment = false, String mode = 'none', String emoji = 'none', String colorPanel = 'none'}) LogError
Configures the visual decoration and color scheme used for log output on the console.
setLockUpdate(bool lock, {String logger = 'Main'}) LogError
Locks or unlocks updates for the specified logger.
setOnLogMessage(dynamic onLogMessage(LogMessage message)?, {String logger = 'Main'}) → dynamic
Sets a callback for log message events.
startTimeLine({String logger = 'Main'}) LogError
Starts a timeline for the specified logger.
stopLoggers() LogError
Stops all active loggers and closes their output files.
stopTimeLine({String logger = 'Main'}) LogError
Stops the timeline for the specified logger.
warning(String category, String message, {String? environment}) LogError
Logs a warning message.