log method

  1. @override
List<String> log(
  1. LogEvent event
)
override

Is called every time a new LogEvent is sent and handles printing or storing the message.

Implementation

@override
List<String> log(LogEvent event) {
  var output = StringBuffer('level=${levelPrefixes[event.level]}');
  if (event.message is String) {
    output.write(' msg="${event.message}"');
  } else if (event.message is Map) {
    event.message.entries.forEach((entry) {
      if (entry.value is num) {
        output.write(' ${entry.key}=${entry.value}');
      } else {
        output.write(' ${entry.key}="${entry.value}"');
      }
    });
  }
  if (event.error != null) {
    output.write(' error="${event.error}"');
  }

  return [output.toString()];
}