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

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

Astute Logger #

pub package License: MIT

A lightweight, production-ready logging package for Flutter applications that provides structured logging, persistent log storage, automatic sensitive data redaction, JSON formatting, execution time measurement, request context support, and colorful console output.

Designed to replace print() with a more powerful, secure, and maintainable logging solution.


โœจ Features #

  • ๐Ÿš€ Structured logging with multiple log levels
  • ๐Ÿ•’ Automatic timestamps for every log
  • ๐Ÿ“ Persistent log file storage
  • ๐Ÿ” Automatic sensitive data redaction
  • ๐ŸŽจ ANSI colored console output
  • ๐Ÿ“ฆ Pretty JSON formatting
  • ๐Ÿ“‹ Pretty list printing
  • โฑ Execution time measurement
  • ๐ŸŒ Request/Zone context support
  • โšก Release mode optimization
  • ๐ŸŒ Unicode & Emoji support
  • ๐Ÿ— Clean and developer-friendly API

๐Ÿ“ฆ Installation #

Add the package to your pubspec.yaml:

dependencies:
  astute_logger: ^latest_version

Then run:

flutter pub get

Import the package:

import 'package:astute_logger/astute_logger.dart';

๐Ÿš€ Quick Start #

Create a logger instance.

final logger = Logger("AuthService");

Write logs.

logger.write(
  message: "User logged in successfully",
  level: LogLevel.info,
);

๐Ÿ“Š Log Levels #

Debug #

logger.write(
  message: "Fetching user profile",
  level: LogLevel.debug,
);

Info #

logger.write(
  message: "User authenticated",
  level: LogLevel.info,
);

Warning #

logger.write(
  message: "API response is taking longer than expected",
  level: LogLevel.warning,
);

Error #

logger.write(
  message: "Database connection failed",
  level: LogLevel.error,
);

๐Ÿ•’ Automatic Timestamp #

Every log automatically includes a timestamp.

Example:

[01-07-2026 15:42:18]

๐Ÿท Class-Based Logging #

Create separate loggers for different classes.

final authLogger = Logger("AuthService");
final apiLogger = Logger("ApiService");

Output:

AuthService::login
ApiService::fetchUsers

This makes it easy to identify where logs originate.


๐Ÿ“ Persistent Log Files #

Logs are automatically saved to persistent storage.

Retrieve the log file:

final file = await Logger.getLogFile();

Useful for:

  • Production debugging
  • User bug reports
  • Offline log collection

๐Ÿ” Automatic Sensitive Data Redaction #

Astute Logger automatically masks sensitive information before writing logs.

Protected data includes:

  • Bearer Tokens
  • JWT Tokens
  • Email Addresses
  • Credit Card Numbers

Example:

Before

Authorization: Bearer eyJhbGciOi...

After

Authorization: Bearer [REDACTED]

No additional configuration is required.


๐Ÿ“ฆ Pretty JSON Logging #

Instead of printing raw JSON:

logger.logJson(response);

Produces beautifully formatted output for easier debugging.


๐Ÿ“‹ Pretty Print Lists #

Print collections in a readable format.

logger.logPrettyList(
  users,
  label: "Users",
);

๐Ÿ“ฆ JSON List Logging #

Pretty print JSON arrays.

logger.logJsonList(users);

โฑ Measure Execution Time #

Measure the execution duration of any operation.

final result = logger.logExecutionTime(
  "Database Query",
  () {
    return fetchUsers();
  },
);

Example output:

Database Query completed in 128 ms

๐ŸŒ Request Context Logging #

Automatically attach request metadata to logs.

await LoggerContext.runWithContext(
  requestId: "REQ-001",
  extra: {
    "userId": "123",
    "platform": "Android",
  },
  body: () {
    logger.write(
      message: "User authenticated",
      level: LogLevel.info,
    );
  },
);

Perfect for:

  • API requests
  • Authentication
  • Distributed tracing
  • Debugging asynchronous operations

๐ŸŽจ Colored Console Output #

Print custom colored logs.

logger.logWithColor(
  "Everything looks good!",
  color: LogColor.green.code,
);

Supported colors include:

  • Green
  • Blue
  • Yellow
  • Red

๐ŸŒ Unicode Support #

Astute Logger fully supports Unicode characters and emojis.

logger.write(
  message: "Hello ๐Ÿ‘‹ ไฝ ๅฅฝ ู…ุฑุญุจุง เคจเคฎเคธเฅเคคเฅ‡",
  level: LogLevel.info,
);

๐Ÿ“– API Overview #

Method Description
write() Write a log message
logJson() Pretty print JSON
logJsonList() Pretty print JSON arrays
logPrettyList() Pretty print Dart lists
logExecutionTime() Measure execution time
logWithColor() Print colored logs
Logger.getLogFile() Retrieve the persistent log file

โœ… Why Astute Logger? #

Unlike simple print() statements, Astute Logger provides:

Feature print() Astute Logger
Log Levels โŒ โœ…
File Logging โŒ โœ…
Colored Output โŒ โœ…
Timestamps โŒ โœ…
JSON Formatting โŒ โœ…
Pretty Lists โŒ โœ…
Request Context โŒ โœ…
Sensitive Data Redaction โŒ โœ…
Execution Time โŒ โœ…
Release Optimization โŒ โœ…

๐Ÿ’ผ Ideal For #

  • Flutter Applications
  • Enterprise Apps
  • Banking Apps
  • Healthcare Applications
  • E-commerce Platforms
  • REST API Clients
  • Production Monitoring
  • Debugging Complex Applications

๐Ÿค Contributing #

Contributions, feature requests, and bug reports are welcome!

If you find a bug or have a suggestion, please open an issue or submit a pull request.


๐Ÿ“„ License #

This project is licensed under the MIT License.

3
likes
145
points
282
downloads

Documentation

API reference

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

License

MIT (license)

Dependencies

flutter, mockito, path_provider

More

Packages that depend on astute_logger