log static method
void
log(
- LogRecord record
Implementation
static void log(LogRecord record) {
var localTime = record.time.toLocal();
var hour = localTime.hour.toString().padLeft(2, "0");
var minute = localTime.minute.toString().padLeft(2, "0");
var second = localTime.second.toString().padLeft(2, "0");
var millisecond = localTime.millisecond.toString().padLeft(3, "0");
var formattedTime = AnsiStyles.gray("$hour:$minute:$second.$millisecond");
var level = record.level.coloredName;
var group =
"[".gray + record.loggerName.padLeft(groupWidth).gray + "]".gray;
var message = StringBuffer(record.message);
var colon = AnsiStyles.gray(":");
if (record.object != null &&
record.error != null &&
record.error is StackTrace) {
message.write("\n${record.error}");
} else {
if (record.error != null) message.write(": ${record.error}");
if (record.stackTrace != null) message.write("\n${record.stackTrace}");
}
var finalMessage = "$formattedTime $level $group$colon $message";
if (noAnsi) finalMessage = AnsiStyles.strip(finalMessage);
print(finalMessage);
}