LogFactory class abstract

A base class for building structured logging mechanisms within Jet-based applications.

This class provides an in-memory logging facility with support for multiple LogLevels. Subclasses can extend this base to implement custom logging strategies (e.g., file, console, remote).

Each logger instance is tagged with a custom tag to allow filtering or identification in composite logs.

Usage

Extend this class to build a concrete logger:

class ConsoleLogger extends LoggerFactory {
  ConsoleLogger(String tag) : super(tag);

  void flush() {
    _logs.forEach((level, messages) {
      for (final message in messages) {
        print('[$tag][$level] $message');
      }
    });
  }
}

Then use:

final logger = ConsoleLogger("MyService");
logger.add(LogLevel.info, "Service started.");
logger.add(LogLevel.error, "Something went wrong.");
logger.flush();
Implementers

Constructors

LogFactory(String tag, {bool canPublish = true, LoggingListener? logListener})
Constructs the logger factory with the given tag.

Properties

canPublish bool
Whether the logger can publish logs to the console.
final
entry → _LogFactoryEntry
Returns the log entry for the current logger.
no setter
hashCode int
The hash code for this object.
no setterinherited
logListener LoggingListener?
The LogListener to use for this factory.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tag String
A custom label or category used to identify the logger instance.
final

Methods

add(LogLevel level, String message, {Object? error, StackTrace? stacktrace}) → void
Adds a message to the log buffer under the specified level.
addAll(_LogFactoryEntry entry) → void
Adds all logs from the given entry to the internal super entry buffer.
clear() → void
Clears all logs from every LogLevel.
getError(_LogFactoryContent content) Object?
Returns the error from the given content.
getIsDebugEnabled() bool
Returns whether DEBUG-level logging is currently enabled.
getIsErrorEnabled() bool
Returns whether ERROR-level logging is currently enabled.
getIsFatalEnabled() bool
Returns whether FATAL-level logging is currently enabled.
getIsInfoEnabled() bool
Returns whether INFO-level logging is currently enabled.
getIsTraceEnabled() bool
Returns whether TRACE-level logging is currently enabled.
getIsWarnEnabled() bool
Returns whether WARN-level logging is currently enabled.
getMessage(_LogFactoryContent content) String
Returns the message from the given content.
getProperty(String key) String?
Retrieves the property value associated with key.
inherited
getStackTrace(_LogFactoryContent content) StackTrace?
Returns the stack trace from the given content.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
publish() → void
Publishes all logs to the console.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

clearGlobalLoggingListener() → void
Clears the global LoggingListener.
getLog(Type type, {bool canPublish = true}) Log
Returns a new Log instance for the given type.
setGlobalLoggingListener(LoggingListener listener) → void
Assigns a global LoggingListener that applies to all LogFactory instances.