talker_logger 4.4.5 talker_logger: ^4.4.5 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
Get Started #
Follow these steps to use this package
Add dependency #
dependencies:
talker_logger: ^4.4.5
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