ConsoleTransport constructor

ConsoleTransport({
  1. bool diffTime = false,
  2. bool alignMessages = false,
  3. int initialAlignmentValue = 0,
  4. String timestampFormat = 'yyyy-MM-dd HH:mm:ss.S',
  5. PrintingMethod printingMethod = PrintingMethod.print,
  6. 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;
}