scoped_logger

A VERY minimalist dart logger.

void main() {
  final logger = ScopedLogger(
    // Adds a simple handler that prints all logs to the console.
    handlers: [PlainTextPrinter()], 
  );

  final serviceLogs = <Log>[];
  final serviceLogger = logger.beginScope('Service', handlers: [
    // Adds a custom handlers that adds all service logs in the list
    LogsHandler.inline((log) => serviceLogs.add(log)),
  ]);

  logger.i('Starting the app'); // prints: [i] Starting the app
  serviceLogger.d('Starting the service...'); // prints: [i][Service1] Starting the service...

  print(serviceLogs); // prints: [[i][Service1] Starting the service...]
}

Libraries

scoped_logger