flutter_devlog 0.3.0
flutter_devlog: ^0.3.0 copied to clipboard
A lightweight, extensible colored console logger for Flutter with structured log records, source location, JSON, levels, tags and scopes.
0.3.0 #
Production-safe: assert()-based tree-shaking.
Every log call (log, lazy, json, configure, reset) is now wrapped in
an assert(() { ...; return true; }()) block. Dart/Flutter removes all
assert() calls at compile time when building with --no-enable-asserts (the
default for flutter build apk, flutter build ipa, flutter build web, and
every AOT release build). This means zero bytes of logging code exist in
your release binary — it is a compiler-level guarantee, not a runtime check.
This supersedes the previous kReleaseMode runtime guard (which kept the code
in the binary but short-circuited it). The new approach is the idiomatic Dart
pattern used by the Flutter framework itself.
Changes:
configure()andreset()are also assert-wrapped and are no-ops in release.enablednow defaults totrue(theassert()wrapper is the debug-only gate; settingenabled = falseis still the way to silence the logger in debug/profile builds).import 'package:flutter/foundation.dart'removed — no longer needed.
No breaking API changes. Users do not need to update any call sites.
0.2.0 #
New features:
-
Release builds are now always silent: even
DevLog.enabled = truehas no effect in release mode. The check is a compile-time constant (kReleaseMode), so logging code is tree-shaken out of release builds.enablednow only controls debug and profile builds. -
Structured log sink:
DevLog.onLognow receives aLogRecordwith the level, raw message (no ANSI codes), channel name, tag, error, stack trace, timestamp, and source location. Userecord.formattedfor the colored console string. -
DevLog.configure(...)to set several options in one call andDevLog.reset()to restore all defaults (handy in testtearDown). -
Tag filtering:
DevLog.allowedTags(allowlist) andDevLog.blockedTags(denylist). -
Timestamps: set
DevLog.showTimestamps = truefor anHH:mm:ss.SSSprefix. -
ScopedLoggerparity:lazy(),child()for nested scopes (Auth/Login), alabelparameter onjson(), anderror/stackTraceparameters onlog(). -
DevLog.jsonnow accepts alevel(defaults to the newLogLevel.json) and respectsminPrioritylike every other log.
Breaking changes:
-
DevLog.onLogchanged fromvoid Function(String message, String name)tovoid Function(LogRecord record). Errors and stack traces are no longer delivered as separate/ERRand/STKcalls; they are fields on the record. Migration:// Before DevLog.onLog = (message, name) => file.writeln('[$name] $message'); // After DevLog.onLog = (record) => file.writeln('[${record.name}] ${record.message}'); -
The
sourceSkipparameter was removed fromDevLog.log. The source location is now resolved automatically and stays correct through wrappers. -
DevLog.jsonprints the title and JSON body as a single log entry instead of two, and is filtered byminPriority(priorityinfoby default).
0.1.0 #
Initial release.
- Leveled colored logging:
info,success,warn,error,api,storage,ui. - Custom
LogLevelsupport withLogPriorityfor filtering. - Optional
[file:line]source location (DevLog.includeSource). errorandstackTraceparameters forwarded todart:developer.- Tagged logging (
tag:) and per-moduleDevLog.scoped()loggers. DevLog.minPriorityfilter andDevLog.lazy()for deferred messages.- Pretty JSON logging via
DevLog.json. - Pluggable output via
DevLog.onLog; debug-only by default.