TomLogger class

The main logger class providing structured logging capabilities.

TomLogger provides multiple log levels and supports customization through:

  • Global log level settings
  • Per-class/method log level overrides
  • Pluggable output destinations
  • Stack trace analysis for automatic origin detection

Basic Usage

Use the global tomLog instance for most logging:

tomLog.info('Server started on port 8080');
tomLog.debug('Processing request: $requestId');
tomLog.error('Failed to connect to database');

Log Level Configuration

// Set global log level
tomLog.setLogLevel(TomLogLevel.development);

// Temporarily increase verbosity
tomLog.pushLogLevel(TomLogLevel.trace);
// ... verbose operations ...
tomLog.popLogLevel();

// Set level for specific class/method
tomLog.addNameLevel('MyClass', TomLogLevel.debug);
tomLog.addNameLevel('MyClass.sensitiveMethod', TomLogLevel.trace);

Custom Output

// Redirect output to a custom destination
tomLog.logOutput = MyCustomLogOutput();

Constructors

TomLogger()

Properties

hashCode int
The hash code for this object.
no setterinherited
logLevel TomLogLevel
The current effective log level.
no setter
logOutput TomLogOutput
The current log output destination.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addNameLevel(String t, TomLogLevel tll) → void
Adds a custom log level for a specific method, class, or member.
debug(Object s) → void
Logs a debug message.
error(Object s) → void
Logs an error message.
fatal(Object s) → void
Logs a fatal error message.
getNameLevel(String t) TomLogLevel?
Gets the custom log level for a specific name.
info(Object s) → void
Logs an informational message.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
output(TomLogLevel messageLogLevel, String level, Object message) → void
Outputs a log message through the configured logOutput.
popLogLevel() → void
Restores the previous log level from the stack.
pushLogLevel(TomLogLevel l) → void
Pushes a new log level onto the level stack.
removeNameLevel(String t) → void
Removes the custom log level for a specific name.
setLogLevel(TomLogLevel l) → void
Sets the current log level.
setLogLevelByName(String levelName) → void
Sets the log level by its string name.
setLogLevelExceptions(String pattern) → void
Configures multiple per-name log level exceptions from a pattern string.
severe(Object s) → void
Logs a severe error message.
status(Object s) → void
Logs a status message.
toString() String
A string representation of this object.
override
trace(Object s) → void
Logs a trace message.
traffic(Object s) → void
Logs a traffic message.
warn(Object s) → void
Logs a warning message.

Operators

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

Static Properties

globalSettingDebugEnabled bool
Global toggle for debug-level logging.
getter/setter pair
globalSettingDetermineCaller bool
Controls whether the logger analyzes the stack trace to determine the caller.
getter/setter pair
globalSettingErrorEnabled bool
Global toggle for error-level logging.
getter/setter pair
globalSettingFatalEnabled bool
Global toggle for fatal-level logging.
getter/setter pair
globalSettingInfoEnabled bool
Global toggle for info-level logging.
getter/setter pair
globalSettingSevereEnabled bool
Global toggle for severe-level logging.
getter/setter pair
globalSettingStatusEnabled bool
Global toggle for status-level logging.
getter/setter pair
globalSettingTraceEnabled bool
Global toggle for trace-level logging.
getter/setter pair
globalSettingTrafficEnabled bool
Global toggle for traffic-level logging.
getter/setter pair
globalSettingWarnEnabled bool
Global toggle for warning-level logging.
getter/setter pair

Constants

DEBUG → const String
ERROR → const String
fallback → const Type
FATAL → const String
INFO → const String
SEVERE → const String
STATUS → const String
TRACE → const String
TRAFFIC → const String
WARN → const String