Modifying the Logger

The CodenicLogger is an extension of the logger package. This means that it has same parameters as its parent, specifically the LogLevel, LogFilter, and LogOutput. These parameters can be modified when the CodenicLogger is instantiated.

With regards to the printer, the CodenicLogger can only accept a special printer called MessageLogPrinter which enforces a fixed structure for the printed logs.

/// CODE FORKED FROM https://pub.dev/packages/logger#options    

final codenicLogger = CodenicLogger(
  filter: null, // Use the default LogFilter (-> only log in debug mode)
  output: null, // Use the default LogOutput (-> send everything to console)
  printer: MessageLogPrinter(
    methodCount: 2, // number of method calls to be displayed
    errorMethodCount: 8, // number of method calls if stacktrace is provided
    lineLength: 120, // width of the output
    colors: true, // Colorful log messages
    printEmojis: true, // Print an emoji for each log message
    printTime: false // Should each log print contain a timestamp
    stackTraceBlocklist: [ // Blocklists the stack trace lines that matches any of the regex
      RegExp('package:codenic_logger/'),
      RegExp('package:codenic_bloc_use_case/'),
    ],
  ),
);

Last updated