log method
void
log(
- String level,
- String message, {
- String? tag,
- dynamic ex,
- StackTrace? stacktrace,
- Map<
String, String?> ? attributes,
override
Logs message
with level
and optional tag
, ex
(exception, stacktrace
Implementation
@override
void log(
String level,
String message, {
String? tag,
dynamic ex,
StackTrace? stacktrace,
Map<String, String?>? attributes,
}) {
final logTag = tag ?? LogTree.getTag();
final logLineBuilder = StringBuffer('$level\t$logTag:\t $message');
if (ex != null) {
logLineBuilder.write('\n$ex');
}
if (stacktrace != null) {
final tmpStacktrace = stacktrace.toString().split('\n');
final stackTraceMessage =
tmpStacktrace.map((stackLine) => '\t$stackLine').join('\n');
logLineBuilder.write('\n$stackTraceMessage');
}
printLog(logLineBuilder.toString(), level: level);
}