BloomLogger class

Standardized structured logging system for Bloom servers, apps, and microservices.

BloomLogger formats log messages with timestamps, ANSI colorized severity tags, hierarchical context identifiers, and structured error/stackTrace outputs.

Features

  • Hierarchical Sub-Contexts: Create sub-loggers using child (e.g., 'API' -> 'API:AUTH').
  • Configurable Severity: Filter messages at runtime with level.
  • Pluggable Output: Intercept and redirect output lines with writer.

Example

final logger = BloomLogger(context: 'HTTP', level: BloomLogLevel.info);

logger.info('Server started on port 8080');
logger.debug('This message will be skipped because level is INFO');

final authLogger = logger.child('AUTH');
authLogger.warn('Invalid login attempt for user alice');

try {
  throw StateError('Database connection dropped');
} catch (e, st) {
  logger.error('Failed to query user', e, st);
}

Constructors

BloomLogger({String context = 'BLOOM', BloomLogLevel level = BloomLogLevel.debug, BloomLogWriter writer = print})
Creates a BloomLogger with an optional context tag, minimum severity level, and log writer.

Properties

context String
Context tag identifying the subsystem, module, or component producing the logs.
final
hashCode int
The hash code for this object.
no setterinherited
level BloomLogLevel
Current minimum severity level required for a message to be logged.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
writer BloomLogWriter
Output destination function for formatted log lines (defaults to print).
getter/setter pair

Methods

child(String subContext) BloomLogger
Creates a child logger with subContext appended to this logger's context.
debug(dynamic message, [Object? error, StackTrace? stackTrace]) → void
Logs a message at the BloomLogLevel.debug level with optional error and stackTrace.
error(dynamic message, [Object? error, StackTrace? stackTrace]) → void
Logs a message at the BloomLogLevel.error level with optional error and stackTrace.
info(dynamic message, [Object? error, StackTrace? stackTrace]) → void
Logs a message at the BloomLogLevel.info level with optional error and stackTrace.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
warn(dynamic message, [Object? error, StackTrace? stackTrace]) → void
Logs a message at the BloomLogLevel.warn level with optional error and stackTrace.

Operators

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