astute_logger 2.0.0 copy "astute_logger: ^2.0.0" to clipboard
astute_logger: ^2.0.0 copied to clipboard

A simple and powerful logger for Flutter apps with support for color-coding, JSON pretty-printing, and performance tracking.

🌟 AstuteLogger #

Lightweight, performant logging for Flutter with file persistence, remote forwarding, and automatic redaction.

Pub Version License: MIT Flutter


Overview #

AstuteLogger is a small, dependency-light logging utility designed for Flutter apps. It gives you:

  • Colored console output for development
  • Optional file logging (persist logs on device)
  • Remote forwarding via customizable callback
  • Automatic redaction of sensitive fields (password, token, access_token, refresh_token)
  • Async queueing to avoid UI jank
  • Test-friendly console override

AstuteLogger is ideal for mobile apps where simple, safe, and performant logging is required.


Features (short) #

  • Console & file logging
  • Remote log forwarding
  • Redaction patterns with easy extension
  • Pretty-print JSON & lists
  • Search, pagination, reversed dumps from file
  • Share logs using SharePlus v12
  • Disabled in kReleaseMode by default

Installing #

Add the package to your pubspec.yaml:

dependencies:
  astute_logger: ^1.0.0

Then run:

flutter pub get

Quick Example #

import 'package:astute_logger/astute_logger.dart';

final logger = AstuteLogger('MyApp', enableFileLogging: true);

await logger.initFileLogging();

logger.info('App started');
logger.debug('Config: ${config.toJson()}');

await logger.dispose();

API — Common Use Cases #

Create logger #

final logger = AstuteLogger(
  'ServiceName',
  enableFileLogging: true,
  enableRemote: false,
  fileNamePrefix: 'app_log',
);

File logging initialization #

await logger.initFileLogging();

Logging #

logger.debug('Detailed dev info');
logger.info('User logged in', tag: 'AUTH');
logger.warning('Slow response time', tag: 'NETWORK');
logger.error('Unhandled exception', tag: 'ERROR');

Pretty JSON & Lists #

logger.logJson(userMap);
logger.logPrettyList(items, label: 'Items');

Share & Inspect Logs #

await logger.shareLogFile(subject: 'App logs', text: 'See attached');
await logger.printLogsPaginated(chunkSize: 200, reverse: true);
await logger.searchLogs(keywords: ['timeout', 'api'], reverse: true);

Test mode #

AstuteLogger.consoleOverride = (msg) => capturedLogs.add(msg);
// ... tests
AstuteLogger.consoleOverride = null;

Redaction #

AstuteLogger ships with default redaction patterns. Add custom patterns if you need to redact more fields:

AstuteLogger.globalRedactionPatterns.add(
  RegExp(r'("api_key"\s*:\s*")[^"]+("")', caseSensitive: false),
);

Performance & Safety #

  • Logging runs asynchronously through an internal StreamController which avoids blocking the main thread.
  • File writes use IOSink with append and flush semantics.
  • In release builds (kReleaseMode) the logger is inert by default.

Platforms #

Supported platforms: Android, iOS, Web, macOS, Windows, Linux.


Contributing #

Contributions welcome. Please open issues or PRs on GitHub: https://github.com/vrs600/astute_logger


License #

MIT — see LICENSE

3
likes
0
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

A simple and powerful logger for Flutter apps with support for color-coding, JSON pretty-printing, and performance tracking.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

flutter, path, path_provider, share_plus

More

Packages that depend on astute_logger