Dancer2::Logger::Console::Colored - Dancer2 colored console logger.
version 0.004
This is a logging engine that allows you to print colored debug messages on the standard error output. It is based on Dancer2::Logger:Console. Refer to its documentation for how to configure the format of your log message.
Writes the log message to the console.
The setting logger should be set to Console::Colored in order to use this logging engine in a Dancer2 application.
logger
Console::Colored
In your config.yml (or $environment.yml):
engines: logger: Console::Colored: colored_origin: "cyan" colored_levels: core: "bold bright_white" debug: "bold bright_blue" info: "bold green" warning: "bold yellow" error: "bold yellow on_red" colored_messages: core: "bold bright_white" debug: "bold bright_blue" info: "bold green" warning: "bold yellow" error: "bold yellow on_red"
You can also provide a configuration key colored_regex, which will allow you to give multiple pairs of regular expression patterns and colors. The logger will then change the colors of anything that matches a pattern according to the configuration.
colored_regex
To enable it, use this (additional) configuration.
colored_regex: - re: "customer number \d+" color: "bold red"
It can also be used to highlight full lines. Just provide a pattern that grabs everything.
colored_regex: - re: ".+error.+" color: "white on_red"
Note that in YAML and other config formats, the pattern can only be a string. If you enable this from within your application, you also also need to supply a string, not a qr//.
qr//
$logger->colored_regex( [ { re => 'foobar', color => 'cyan', }, { re => '\d+', color => 'magenta', }, ] );
If you are running on Dancer2 older than 0.166001_01 you will need to use Dancer2::Logger::Console::Colored version 0.001 because Dancer2 changed the way the logging was handled.
Dancer2::Logger::Console, Dancer2::Core::Role::Logger, Term::ANSIColor
BURNERSK <burnersk@cpan.org>
This software is Copyright (c) 2014 by BURNERSK <burnersk@cpan.org>.
This is free software, licensed under:
The MIT (X11) License
To install Dancer2::Logger::Console::Colored, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2::Logger::Console::Colored
CPAN shell
perl -MCPAN -e shell install Dancer2::Logger::Console::Colored
For more information on module installation, please visit the detailed CPAN module installation guide.