log library

Log primitives and global loggers. Names like log, logWriter, LogLevel, and LogScope are intentionally kept off the main serverpod_shared barrel because they collide with common user identifiers; import this library when you need them.

Classes

ActiveScope
State for a single in-progress scope with a braille spinner.
ClosedScope
A completed scope record for test assertions.
IsolatedLogWriter
A LogWriter that runs a wrapped writer on a dedicated isolate.
Log
A logger that delegates to a LogWriter and resolves the current LogScope from the Zone.
LogEntry
A single log entry. Always belongs to a LogScope.
LogScope
A scoped operation. Scopes form a tree - every scope has a parent except the root scope.
LogWriter
Transport layer for log output. Implementations decide where logs go (terminal, database, VM service, TUI, etc.).
MultiLogWriter
A LogWriter that fans out to multiple child writers.
SpinnerLogWriter
A LogWriter base class that manages braille progress spinners.
TestLogWriter
A LogWriter that collects entries and scopes for test assertions.
TextLogWriter
A SpinnerLogWriter that writes formatted text to stdout/stderr.

Enums

LogLevel
Log severity level.

Extensions

LogConvenience on Log
Convenience methods for common log levels.
LogScoping on Log
Scope management: progress operations and manual scope control.

Constants

serverpodLogEvent → const String
The VM service extension event carrying the pod's log entries and scopes.

Properties

isInteractiveTerminal ↔ bool
Whether stdout is an interactive terminal.
getter/setter pair
log → Log
Global Log that forwards to logWriter. Identity is stable: the instance is constructed at library init and never reassigned. Entry points configure logging by mutating logWriter, not by replacing log.
final
logWriter → MultiLogWriter
Global writer chain that backs log. Callers configure the chain by adding writers with MultiLogWriter.add and removing them with MultiLogWriter.remove; identity is stable for the process lifetime, so the chain is shared across any number of Log consumers and framework bootstraps.
final

Functions

decodeLogEntry(Map<String, Object?> json, {String fallbackScopeLabel = ''}) → LogEntry
Decodes what encodeLogEntry, or a pod older than it, produced.
encodeLogEntry(LogEntry entry) → Map<String, Object?>
Encodes entry as the JSON the pod posts and the runner forwards.
formatElapsed(Duration d) → String
Format a duration for display in spinner/completion lines.
parseLogLevel(String? name) → LogLevel
The LogLevel that name denotes, or LogLevel.info if none does.

Typedefs

LogEntryFactory = FutureOr<LogEntry> Function()
A factory function that creates a LogEntry.