struct_log 0.3.0
struct_log: ^0.3.0 copied to clipboard
Structured logging for Dart with pluggable sinks, OpenTelemetry-compatible context (spanId/traceId), and zero Flutter dependency.
Changelog #
0.3.0 #
- Nullable attribute values —
LogRecord.attributeswidened fromMap<String, Object>toMap<String, Object?>. Logger method signatures updated toMap<String, Object?>?. Allows callers to distinguish "field present but null" from "field absent" — important for structured logging of optional fields (e.g.,{'userId': null}). Fixes dart_monty#216.
0.2.0 #
LogManager.scoped()— named constructor that creates an independentLogManagerinstance with its own sink list and minimum level. Enables test isolation without mutating the global singleton. Fixes dart_monty#194.final class LogManager— prevents subclassing. The publicscoped()constructor would have allowedextends LogManager;finalrestores the original sealed-by-private-constructor intent.
0.1.0 #
- Initial release of
struct_log. LogLevel— six-level severity enum (trace, debug, info, warning, error, fatal) with OTel-standard names and numeric values.LogRecord— immutable structured log record withspanId,traceId, andMap<String, Object> attributesfor telemetry correlation.LogSink— abstract interface withwrite/flush/closelifecycle.LogManager— singleton sink manager with fan-out, level filtering, and fault isolation (failing sinks do not crash the app).Logger+LoggerFactory— named logger facade with level methods.MemorySink— O(1) circular buffer with liveonRecordstream andonClearnotification. Ideal for debugging UIs and test assertions.ConsoleSink— platform-adaptive sink usingdart:developer(native) and browserconsoleAPI (web).StdoutSink— platform-adaptive sink usingdart:iostdout with optional ANSI color codes. No-op on web.