clever_logger 1.1.0+1 icon indicating copy to clipboard operation
clever_logger: ^1.1.0+1 copied to clipboard

An easy to use, highly extendable logger library with colorful prints.

Clever Logger #

style: very good analysis Powered by Mason License: MIT Coverage

An extendable logger library with colorful prints.

Basic Usage ๐Ÿš€ #

You can log messages with different levels of severity.

The default levels are the following:

  • fine
  • info
  • config
  • warning
  • shout

To log a message at level info with the default logger:

logInfo('Hello there!');

This prints this message to the console.

[Logger - INFO] Hello there!

Create a logger and use it to log messages.

final logger = CleverLogger('Test Logger');
// now you can use this logger
logger.logFine('Hello there!');

Advanced Usage ๐Ÿงช #

Log Actions #

Log actions are responsible for what happens with the logs (for example storing them in a file or sending them to your analytics service).

The LogRecords are passed to the actions in order. By default, the logger uses a ColorfulPrintAction as its default action, which is responsible for colorful outputs to the console.

final otherLogger = CleverLogger(
  'Other Logger',
  logActions: [
    // The default colorful console output.
    // A custom action

Log actions can also be configured to only run for logs with a certain level.

class MyLogAction extends LogAction {
  Level get level => Level.INFO;

  void onRecord(LogRecord record) {
    //This is only executed for logs with a level >=
    print('${record.loggerName} has a log with ${record.level}');

Extending functionality #

You can write extension methods to extend the loggers functionality. Additional values can be stored in the value variable of the logger.

By default, the logger has a Stopwatch integrated as an extension.

See the example for more information.

Custom Printer #

Extend the ColorfulPrintAction and override the default print functions, like printInfo, printWarning etc. for custom-styled print messages.

You can use the ansicolor plugin for colorful prints.

pub points


verified publisher

An easy to use, highly extendable logger library with colorful prints.

Repository (GitHub)
View/report issues


API reference


Icon for licenses.MIT (LICENSE)


ansicolor, logging


Packages that depend on clever_logger