Skip to content

Instantly share code, notes, and snippets.

@yrom

yrom/logging.dart

Created Jul 8, 2020
Embed
What would you like to do?
Flutter logging
import 'package:logging/logging.dart';
import 'dart:developer' as developer;
void initLogging() {
// disable hierarchical logger
hierarchicalLoggingEnabled = false;
// change to another level as needed.
Logger.root.level = Level.INFO;
// skip logging stactrace below the SEVERE level.
recordStackTraceAtLevel = Level.SEVERE;
assert(() {
recordStackTraceAtLevel = Level.WARNING;
// print all logs on debug build.
Logger.root.level = Level.ALL;
return true;
}());
Logger.root.onRecord.listen((event) {
developer.log(
event.message,
time: event.time,
sequenceNumber: event.sequenceNumber,
level: event.level.value,
name: event.loggerName,
zone: event.zone,
error: event.error,
stackTrace: event.stackTrace,
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.