AtSignLogger constructor

AtSignLogger(
  1. String name, {
  2. LoggingHandler? loggingHandler,
})

The AtSignLogger is a wrapper on the Logger to log events.

  • name: Accepts String as input which represents the name of the AtSignLogger instance.

  • loggingHandler This is an optional parameter that determines the destination for logging events.

The loggingHandler defaults to the value of defaultLoggingHandler.

To customize the logging behavior based on your specific requirements, create an instance of a class that implements the LoggingHandler interface and pass this instance to the loggingHandler argument

class MyLoggingHandler implements LoggingHandler {
  @override
  void call(LogRecord record) {
    // Custom implementation of logging behavior
    print('Logging: ${record.message}');
  }
}

AtSignLogger('myLogger', loggingHandler: MyLoggingHandler())

Implementation

AtSignLogger(String name, {LoggingHandler? loggingHandler}) {
  logger = logging.Logger.detached(name);
  loggingHandler ??= defaultLoggingHandler;
  // ignore: implicit_call_tearoffs
  logger.onRecord.listen(loggingHandler);
  level = _root_level;
}