simplest_logger 0.0.4 copy "simplest_logger: ^0.0.4" to clipboard
simplest_logger: ^0.0.4 copied to clipboard

A lightweight, opinionated, colorful logging utility for Dart applications. Minimal configuration necessary.

simplest_logger #

A lightweight, opinionated, colorful logging utility for Dart applications that provides an easy-to-use interface for console logging with minimal configuration.

  • Colored console output (info: green, warning: yellow, debug: blue, error: red)
  • Automatic timestamps for all log messages
  • Automatic class name labeling
  • Simple mixin for quick integration
  • Runtime-configurable logging levels (both globally and per-instance)
  • Global configuration support
  • Zero dependencies

Usage #

The most basic usage is to use the SimplestLogger class directly:

final logger = SimplestLogger('MyClass', LogLevel.all);
logger.info('Application started');    // Green output
logger.warning('Cache miss');          // Yellow output
logger.debug('Processing request');    // Blue output
logger.error('Connection failed');     // Red output

For a more integrated approach, you can use the SimplestLoggerMixin mixin:

class MyService with SimplestLoggerMixin {
  void doSomething() {
    logger.info('Operation started');
  }
}

Controlling log levels #

You have three ways to control logging behavior:

  1. Globally using SimplestLoggerConfig:
// Turn off all logging across the app
SimplestLoggerConfig.globalLogLevel = LogLevel.off;

// Make loggers ignore global settings (use their individual settings)
SimplestLoggerConfig.respectGlobalLogLevel = false;
  1. Per instance when creating a SimplestLogger:
final logger = SimplestLogger('MyClass', LogLevel.off);
  1. Per mixin by setting the logLevel property:
class ProductionService with SimplestLoggerMixin {
    ProductionService() {
        // Disable logging for this service
        logLevel = LogLevel.off;
    }
}

By default:

  • Global logging is enabled (LogLevel.all)
  • Global settings are respected (respectGlobalLogLevel = true)
  • Individual loggers can override the global setting if respectGlobalLogLevel is set to false

License #

This project is licensed under the MIT License - see the LICENSE file for details.

0
likes
0
points
48
downloads

Publisher

verified publisherbizjak.dev

Weekly Downloads

A lightweight, opinionated, colorful logging utility for Dart applications. Minimal configuration necessary.

Repository (GitLab)
View/report issues

Topics

#logging

License

unknown (license)

More

Packages that depend on simplest_logger