Logger constructor

Logger(
  1. String name
)

Implementation

Logger(String name) {
  g.Logger.root.level = g.Level.ALL;
  g.Logger.root.onRecord.listen((g.LogRecord record) {
    final String? tool = lightCyan.wrap('[${record.time}] ${record.loggerName}:');
    final String? stackTrace = record.stackTrace == null ? '' : darkGray.wrap('\n${record.stackTrace}');
    final String message = ' ${record.message}';
    if (record.level == g.Level.INFO) {
      print('$tool${white.wrap(message)}$stackTrace');
    } else if (record.level == g.Level.FINER) {
      print('$tool${green.wrap(message)}$stackTrace');
    } else if (record.level == g.Level.WARNING) {
      print('$tool${yellow.wrap(message)}$stackTrace');
    } else if (record.level == g.Level.SEVERE) {
      print('$tool${red.wrap(message)}$stackTrace');
    }
  });
  lg = g.Logger(name);
}