output method
Implementation
void output(String msg, {String? className, required String tag, required String color}) {
//
// 0. shorten message
//
int maxLen = Log.MAX_LEN;
if (maxLen > 0) {
msg = Logger.shorten(msg, maxLen);
}
//
// 1. set color
//
String clear;
if (Log.colorful && color.isNotEmpty) {
clear = Logger.clearColor;
} else {
color = '';
clear = '';
}
//
// 2. build body
//
String body;
// 2.1. insert caller & class name
var locate = caller;
if (Log.showCaller) {
if (className == null) {
body = '$locate >\t$msg';
} else {
body = '$locate | $className >\t$msg';
}
} else {
if (className == null) {
body = msg;
} else {
body = '$className >\t$msg';
}
}
// 2.2. insert time & tag
if (Log.showTime) {
body = '[$now] $tag | $body';
} else {
body = '$tag | $body';
}
//
// 3. colored print
//
if (Log.colorful) {
printer.output(body, head: color, tail: clear, tag: tag, caller: locate);
} else {
printer.output(body, tag: tag, caller: locate);
}
}