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

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

example/simplest_logger_example.dart

import 'package:simplest_logger/simplest_logger.dart';

class TestService with SimplestLoggerMixin {
  String performAction(bool shouldSucceed) {
    try {
      logger.info('Starting action');
      if (!shouldSucceed) {
        throw Exception('Test error');
      }

      logger.info('Action completed successfully');
      return 'Success';
    } catch (error, stackTrace) {
      logger.error('Action failed', error, stackTrace);
      rethrow;
    }
  }
}

void main() {
  const logger = SimplestLogger('main');
  logger.init();

  logger.info('This is an info message');
  logger.warning('This is a warning message');
  logger.error('This is an error message');

  logger.setLevel(SimplestLoggerLevel.none);
  logger.info('This is an info message (should not be printed)');

  logger.setLevel(SimplestLoggerLevel.all);
  logger.useColors(false);
  logger.warning('This warning message is without colors');

  logger.useColors(true);

  final testService = TestService();
  testService.performAction(false);
  testService.performAction(true);
}
0
likes
0
points
177
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)

Dependencies

logging

More

Packages that depend on simplest_logger