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

A flexible, scalable, and efficient Flutter application logging library.

Flutter Isolate Logger #

A robust, isolate-based logging package for Flutter applications.

Documentation #

Features #

  • Multiple Outputs: Support for Console, File, and Remote (HTTP) logging.
  • Isolate-based: Heavy logging operations (like file I/O) are performed in a separate isolate to prevent UI jank.
  • Custom Formatting: From date format to full log format, everything can be customized.
  • Standard Levels: Uses the standard logging package levels. Optional error and trace stack output (use stack_trace to improve readability).

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_isolate_logger:
    path: /path/to/flutter_isolate_logger

Usage #

Initialization #

Before using any loggers, initialize the system. This registers the worker types.

import 'package:flutter_isolate_logger/flutter_isolate_logger.dart';

void main() {
  FlutterIsolateLogger.initialize();
  // ...
}

Creating Loggers #

Console Logger

final consoleLogger = ConsoleLogger();
consoleLogger.info('App started', 'Main');

File Logger

final fileLogger = FileLogger(
  logFilePath: 'path/to/app.log',
  maxFileSizeInBytes: 10 * 1024 * 1024, // 10 MB
  maxBackupFiles: 5,
);

Remote Logger

final remoteLogger = RemoteLogger(
  serverUrl: 'https://my-logs.com/api/logs',
);

Multi Logger

Combine multiple loggers:

final multiLogger = MultiLogger(
  loggers: [consoleLogger, fileLogger],
);

multiLogger.info('This goes to both console and file', 'Auth');

Logging #

The loggers support standard log levels:

logger.info('Info message', 'Scope');
logger.warning('Warning message', 'Scope');
logger.severe('Error message', 'Scope', exception, stackTrace);
logger.shout('Critical message', 'Scope');

Disposal #

When the app is shutting down, you can dispose of the logger system:

FlutterIsolateLogger.dispose();

Architecture #

This package uses a LogDispatcher to send log commands to a background isolate. This ensures that file I/O and network requests do not block the main thread.

Benchmarks #

To run the benchmarks and verify the main thread overhead:

dart run benchmark/logger_benchmark.dart

Typical results (on a development machine):

  • Simple Log: ~15 µs per log
  • Log with StackTrace: ~80 µs per log
1
likes
150
points
120
downloads

Publisher

unverified uploader

Weekly Downloads

A flexible, scalable, and efficient Flutter application logging library.

Repository (GitHub)
View/report issues

Topics

#logging #dart-logger

Documentation

API reference

License

MIT (license)

Dependencies

flutter, logging, stack_trace

More

Packages that depend on flutter_isolate_logger