BenNG
BenNG

Reputation: 531

How to implement a logging system in dart

I have a general question on how to proper implement a logging system in dart. I can't find reliable doc on it. Is logging lib up to date ? Thx !

Upvotes: 2

Views: 534

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657338

I think this is the simplest way to set it up

import 'package:logging/logging.dart' show Logger, Level; // every library
import 'package:quiver_log/log.dart'; // library containing main

final _log = new Logger('bwu_model.server.main'); // every library

// main
void main() {
  Logger.root.level = Level.FINEST;
  var appender = new PrintAppender(BASIC_LOG_FORMATTER);
  appender.attachLogger(Logger.root);

  // actual logging
  _log.info('Pub session initialized.');
}

Upvotes: 3

Related Questions