talker_logger 4.3.0 copy "talker_logger: ^4.3.0" to clipboard
talker_logger: ^4.3.0 copied to clipboard

Logger. Easy, customizable, extensible logging, lightweight with filters, formatters, custom logs, log levels.

talker_logger #

Logger. Easy, customizable, extensible logging, lightweight with filters, formatters, custom logs, log levels.

Core talker package
The package is designed to to make simple and extended logs
Can be used separately from the main parent package
In order to use all the functionality - go to the main page

codecov Pub Pub License: MIT talker talker_flutter talker_logger

Get Started #

Follow these steps to use this package

Add dependency #

dependencies:
  talker_logger: ^4.3.0

Easy to use #

Create TalkerLogger instance and call prepared methods

// Create instance
final logger = TalkerLogger();
// Log messages
logger.debug('debug');
logger.info('info');
logger.critical('critical');
logger.error('error');
logger.good('good');
logger.warning('warning');
logger.verbose('verbose');
logger.log('log with level info', level: LogLevel.info);
logger.log('custom pen log', pen: AnsiPen()..xterm(49));

Result

More examples you can get there or in docs

Customization #

This logger has simple settings that can change output

1. Filtering #

  final logger = TalkerLogger(
    settings: const TalkerLoggerSettings(
      // Set current logging level
      level: LogLevel.critical,
    ),
  );

  // Works as before
  logger.critical('critical');
  // Does not work
  logger.info('info');

Result

2. Formating #

Create your own LoggerFormatter implementation For example - ColoredLoggerFormatter that makes messages only with colors

class ColoredLoggerFormatter implements LoggerFormatter {
  @override
  String fmt(LogDetails details, TalkerLoggerSettings settings) {
    final msg = details.message?.toString() ?? '';
    final coloredMsg =
        msg.split('\n').map((e) => details.pen.write(e)).toList().join('\n');
    return coloredMsg;
  }
}

And add formatter for TalkerLogger constructor

  final logger = TalkerLogger(
    formatter: ColoredLoggerFormatter(),
  );

  logger.debug('debug');
  logger.info('info');
  logger.warning('warning');
  logger.error('error');

Result

Or you can make simple customization with default formatters

  final logger = TalkerLogger(
    settings: TalkerLoggerSettings(
      colors: {
        LogLevel.critical: AnsiPen()..yellow(),
        LogLevel.error: AnsiPen()..yellow(),
        LogLevel.info: AnsiPen()..yellow(),
      },
      maxLineWidth: 20,
      lineSymbol: '#',
      enableColors: true,
    ),
  );

  logger.info('info');
  logger.critical('critical');
  logger.error('error');

Result

Coverage #

More examples you can get here

43
likes
160
pub points
89%
popularity

Publisher

verified publisherfrezycode.com

Logger. Easy, customizable, extensible logging, lightweight with filters, formatters, custom logs, log levels.

Repository (GitHub)
View/report issues
Contributing

Topics

#logging #console #cli

Documentation

API reference

License

MIT (LICENSE)

Dependencies

ansicolor

More

Packages that depend on talker_logger