log_plus 0.0.6 copy "log_plus: ^0.0.6" to clipboard
log_plus: ^0.0.6 copied to clipboard

Small, feature-rich logging package for Dart and Flutter. Written in pure Dart, with no dependencies.

example/main.dart

import 'package:log_plus/log_plus.dart';

void main() {
  print(
      'Run with either `dart example/main.dart` or `dart --enable-asserts example/main.dart`.');
  quickStartDemo(); // quick start demo with no customisation
  customiseDemo(); // example of all customisation options
  hideLogsInRelease(); // example of hiding logs in release
}

void quickStartDemo() {
  Logs log = Logs();
  log.v('This is a verbose log');
  log.d('This is a debug log');
  log.i('This is an info log');
  log.w('This is a warning log');
  log.e('This is an error log', includeTrace: true);
}

void customiseDemo() {
  Logs log = Logs(
    storeLogLevel: LogLevel.warning, // only store warning and error logs
    printLogLevelWhenDebug: LogLevel.verbose, // print all logs in debug
    printLogLevelWhenRelease: LogLevel.error, // only print errors in release
    storeLimit: 500, // log history stored in memory
  );
  log.v('This is a verbose log');
  log.d('This is a debug log');
  log.i('This is an info log');
  log.w('This is a warning log');
  log.e('This is an error log', includeTrace: true);

  List<Map> logs = log.getStoredLogs(); // get stored logs as a list
  print(logs);
}

void hideLogsInRelease() {
  Logs log = Logs(
    printLogLevelWhenRelease: LogLevel.none, // disable printing logs in release
  );

  print('All logs will be shown in debug, but hidden in release mode.');

  log.v('This is a verbose log');
  log.d('This is a debug log');
  log.i('This is an info log');
  log.w('This is a warning log');
  log.e('This is an error log', includeTrace: true);
}
4
likes
160
points
79
downloads

Publisher

verified publisherkasibhatla.dev

Weekly Downloads

Small, feature-rich logging package for Dart and Flutter. Written in pure Dart, with no dependencies.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on log_plus