ConsoleTransport constructor
ConsoleTransport({
- bool diffTime = false,
- bool alignMessages = false,
- int initialAlignmentValue = 0,
- String timestampFormat = 'yyyy-MM-dd HH:mm:ss.S',
- PrintingMethod printingMethod = PrintingMethod.print,
- LogecomTextPainter textPainter = const UtfPainter(),
Implementation
ConsoleTransport({
this.diffTime = false,
this.alignMessages = false,
this.initialAlignmentValue = 0,
this.timestampFormat = 'yyyy-MM-dd HH:mm:ss.S',
this.printingMethod = PrintingMethod.print,
this.textPainter = const UtfPainter(),
}) {
if (printingMethod == PrintingMethod.stdOut) {
_printer = (line) => stdout.writeln(line);
} else if (printingMethod == PrintingMethod.stdErr) {
_printer = (line) => stderr.writeln(line);
} else if (printingMethod == PrintingMethod.developerLog) {
_printer = (line) {
final parts = line.split(' ');
developer.log(parts.skip(2).join(' '), name: parts[1]);
};
} else if (printingMethod == PrintingMethod.print) {
_printer = (line) => print(line.replaceAll('\x1B', '\u001B')); // ignore: avoid_print
}
_levelColor[LogLevel.warn] = textPainter.yellow;
_levelColor[LogLevel.info] = textPainter.green;
_levelColor[LogLevel.fatal] = textPainter.red;
_levelColor[LogLevel.error] = textPainter.red;
_levelColor[LogLevel.debug] = textPainter.cyan;
_levelColor[LogLevel.log] = textPainter.white;
_lgp = textPainter.gray;
_gp = textPainter.white;
_timestampFormatter = DateFormat(timestampFormat);
_categoryMaxLength = initialAlignmentValue;
}