Skip to content

Instantly share code, notes, and snippets.

@AlexMeuer
Created July 26, 2020 10:35
Show Gist options
  • Save AlexMeuer/1575f5b88144f287d6396175306d6dbd to your computer and use it in GitHub Desktop.
Save AlexMeuer/1575f5b88144f287d6396175306d6dbd to your computer and use it in GitHub Desktop.
copy-pastable injectable logger config
import 'package:injectable/injectable.dart';
import 'package:logger/logger.dart';
@module
abstract class LoggingModule {
@lazySingleton
Logger get logger;
@dev
@injectable
Level levelDev() => Level.verbose;
@test
@injectable
Level levelTest() => Level.info;
@prod
@injectable
Level levelProd() => Level.wtf;
@injectable
LogFilter filter() => ProductionFilter();
@dev
@injectable
LogPrinter printerDev() => SimplePrinter(colors: false);
@test
@injectable
LogPrinter printerTest() => SimplePrinter(colors: false, printTime: true);
@prod
@injectable
LogPrinter printerProd() => LogfmtPrinter();
@injectable
LogOutput output() => ConsoleOutput();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment