buildMessageText method
Builds a message text to be logged.
Implementation
String buildMessageText(logging.LogRecord msg) {
var time = '${msg.time}'.padRight(26, '0');
var levelName = '[${msg.level.name}]'.padRight(9);
var debugName = isolateDebugName;
if (debugName.isNotEmpty) {
var max = _maxKey('debugName', debugName, 10);
debugName = truncateString(debugName, max);
debugName = '($debugName)'.padRight(max + 2);
}
var loggerName = this.loggerName(msg);
if (loggerName.isNotEmpty) {
var max = _maxKey('loggerName', loggerName, 20);
loggerName = truncateString(loggerName, max);
loggerName = loggerName.padRight(max);
}
var message = msg.message;
var logMsg =
StringBuffer('$time $levelName $debugName $loggerName> $message\n');
if (msg.error != null) {
logMsg.write('[ERROR] ');
logMsg.write(msg.error.toString());
logMsg.write('\n');
}
if (msg.stackTrace != null) {
logMsg.write(msg.stackTrace.toString());
logMsg.write('\n');
}
return logMsg.toString();
}