Log class

Rust-style logger for Dart.

A beautiful logging library that mimics Rust's compiler output format. Features colored output, precise file locations, and clean formatting.

Basic Logging

Log.t('Trace message');     // Most verbose
Log.d('Debug message');     // Development info
Log.i('Info message');      // General info
Log.w('Warning message');   // Potential issues
Log.e('Error message');     // Errors
Log.f('Fatal message');     // Critical failures

Error Logging with Details

try {
  // risky operation
} catch (e, stack) {
  Log.e('Operation failed', error: e, stackTrace: stack);
}

Tag Logging for AI Analysis

Group related logs across layers and export for AI analysis:

// Tag logs across your app
Log.tag('auth', 'User login attempt');
Log.tag('auth', {'userId': 123}, level: Level.INFO);
Log.tag('auth', 'Login failed', level: Level.SEVERE);

// Export to console (copy to Claude for analysis)
Log.export('auth');

See tag, export, and exportAll for more details.

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 Methods

clear(String name) → void
Clears a tag without exporting.
clearAll() → void
Clears all tags without exporting.
d(dynamic message) → void
Logs a debug message.
e(dynamic message, {Object? error, StackTrace? stackTrace}) → void
Logs an error message with optional error object and stack trace.
entryCount(String name) int
Gets the count of entries for a tag.
export(String name, {bool export = true, bool onlyOnError = false}) String?
Exports a tag's logs to console as Markdown and returns the formatted string.
exportAll({bool export = true, bool onlyOnError = false}) Map<String, String>
Exports all tags to console as Markdown and returns them as a map.
f(dynamic message) → void
Logs a critical/fatal message.
hasErrors(String name) bool
Checks if a tag has any error entries (WARNING/ERROR/CRITICAL).
hasTag(String name) bool
Checks if a tag has any logged entries.
i(dynamic message) → void
Logs an info message.
init({Level level = Level.ALL}) → void
Initializes the logger with the desired log level.
t(dynamic message) → void
Logs a trace message (most verbose level).
tag(String name, dynamic message, {Level level = Level.FINE, Object? error, StackTrace? stackTrace}) → void
Logs a message with a tag for grouping and later export.
w(dynamic message) → void
Logs a warning message.