basic_logger_file 0.1.0 copy "basic_logger_file: ^0.1.0" to clipboard
basic_logger_file: ^0.1.0 copied to clipboard

FileOutputLogger adds file logging to BasicLogger for Android, iOS, Linux, macOS, and Windows.

BasicLogger is a fast, extensible, simple and lightweight logging tool for Dart and Flutter.

Features #

FileOutputLogger adds file logging to BasicLogger for Android, iOS, Linux, macOS, and Windows.

Getting started #

  dart pub add basic_logger_file
  flutter pub add basic_logger_file

Usage #

Include short and useful examples for package users. Add longer examples to /example folder.

  Logger.root.level = Level.ALL;
  final basicLogger = BasicLogger('main');

  // attach file log, bufferSize default 10
  basicLogger.attachLogger(FileOutputLogger(basicLogger.name));

  // output to all attach instance
  basicLogger.info('hello world');
  
  // output buffer to all attach instance, not include detach instance
  basicLogger.output();

  // output
  // 2024-10-15 03:03:21.114721 [INFO] main: hello world

Additional information #

  • FileOutputLogger, specify output file path
    var logPath = './logs/';
    /*
    // In Flutter, use the path_provider, get the current application's documents directory.
    final appDocDir = await getApplicationDocumentsDirectory();
    logPath = '${appDocDir.path}/logs/';
    */
    if(!Directory(logPath).existsSync()){
        Directory(logPath).createSync(recursive: true);
    }
    basicLogger.attachLogger(FileOutputLogger(
        basicLogger.name,
        dir: './logs/',
    ));
  • FileOutputLogger, specify output buffer size
  // buffering allows you to write files multiple times instead of writing files once
  basicLogger.attachLogger(FileOutputLogger(
    basicLogger.name,
    bufferSize: 100,
  ));

  // output and clear buffer
  basicLogger.output();
0
likes
160
points
28
downloads

Publisher

verified publisheriche2.com

Weekly Downloads

FileOutputLogger adds file logging to BasicLogger for Android, iOS, Linux, macOS, and Windows.

Homepage
Repository (GitHub)

Topics

#logging #console #debug #user-logs

Documentation

API reference

License

MIT (license)

Dependencies

basic_logger, logging, path

More

Packages that depend on basic_logger_file