JsonLogger constructor

JsonLogger({
  1. required int logLevel,
  2. RecordMapper? mapper,
  3. JsonSerializer? serializer,
  4. void output(
    1. String
    ) = print,
})

The JsonLogger class is a logger that records log messages in JSON format.

It implements the ILogRecorder interface and provides the following features:

  • supports configurable log levels.
  • can be used to record log messages to any output stream, such as the console, a file, or a network socket.
  • uses a customizable mapper to convert LogRecordEntity objects to JSON maps.
  • uses a customizable serializer to serialize JSON maps to strings.

Implementation

JsonLogger({
  required this.logLevel,
  RecordMapper? mapper,
  JsonSerializer? serializer,
  this.output = print,
})  : mapper = mapper ?? _defaultMapper,
      serializer = serializer ?? jsonEncode;