Skip to content

Commit

Permalink
add attribution about idea
Browse files Browse the repository at this point in the history
  • Loading branch information
simbabque committed Jul 8, 2017
1 parent 9d5028a commit caf8b02
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 53 deletions.
114 changes: 61 additions & 53 deletions README.md
Expand Up @@ -3,80 +3,88 @@
Mojo::Log::Colored - Colored Mojo logging

<div>
# SYNOPSIS

use Mojo::Log::Colored;

# Log to STDERR
$app->log(
Mojo::Log::Colored->new(
# optionally set the colors
colors => {
debug => "bold bright_white",
info => "bold bright_blue",
warn => "bold green",
error => "bold yellow",
fatal => "bold yellow on_red",
}
)
);

# DESCRIPTION

Mojo::Log::Colored is a logger for Mojolicious with colored output for the terminal. It lets you define colors
for each log level based on L<Term::ANSIColor> and comes with sensible default colors. The full lines in the log
will be colored.

Since this inherits from L<Mojo::Log> you can still give it a C<file>, but the output would also be colored.
That does not make a lot of sense, so you don't want to do that. Use this for development, not production.

# ATTRIBUTES
<p>
<a href="https://travis-ci.org/simbabque/Mojo-Log-Colored"><img src="https://travis-ci.org/simbabque/Mojo-Log-Colored.svg?branch=master"></a>
<a href='https://coveralls.io/github/simbabque/Mojo-Log-Colored?branch=master'><img src='https://coveralls.io/repos/github/simbabque/Mojo-Log-Colored/badge.svg?branch=master' alt='Coverage Status' /></a>
</p>
</div>

L<Mojo::Log::Colored> implements the following attributes.
# SYNOPSIS

## colors
use Mojo::Log::Colored;

my $colors = $log->colors;
$log->colors(
{
# Log to STDERR
$app->log(
Mojo::Log::Colored->new(
# optionally set the colors
colors => {
debug => "bold bright_white",
info => "bold bright_blue",
warn => "bold green",
error => "bold yellow",
fatal => "bold yellow on_red",
}
);
)
);


# DESCRIPTION

Takes a hash reference with the five log levels as keys and strings of colors as values. Refer to
L<Term::ANSIColor> for more information about what kind of color you can use.
Mojo::Log::Colored is a logger for Mojolicious with colored output for the terminal. It lets you define colors
for each log level based on [Term::ANSIColor](https://metacpan.org/pod/Term::ANSIColor) and comes with sensible default colors. The full lines in the log
will be colored.

## format
Since this inherits from [Mojo::Log](https://metacpan.org/pod/Mojo::Log) you can still give it a `file`, but the output would also be colored.
That does not make a lot of sense, so you don't want to do that. Use this for development, not production.

my $cb = $log->format;
$log = $log->format( sub { ... } );
# ATTRIBUTES

[Mojo::Log::Colored](https://metacpan.org/pod/Mojo::Log::Colored) implements the following attributes.

A callback for formatting log messages. Cannot be passed to C<new> at construction! See L<Mojo::Log> for more information.
## colors

# METHODS
my $colors = $log->colors;
$log->colors(
{
debug => "bold bright_white",
info => "bold bright_blue",
warn => "bold green",
error => "bold yellow",
fatal => "bold yellow on_red",
}
);

L<Mojo::Log::Colored> inherits all methods from L<Mojo::Log> and does not implement new ones.
Takes a hash reference with the five log levels as keys and strings of colors as values. Refer to
[Term::ANSIColor](https://metacpan.org/pod/Term::ANSIColor) for more information about what kind of color you can use.

# SEE ALSO
## format

L<Mojo::Log>, L<Term::ANSIColor>
my $cb = $log->format;
$log = $log->format( sub { ... } );

# LICENSE
A callback for formatting log messages. Cannot be passed to `new` at construction! See [Mojo::Log](https://metacpan.org/pod/Mojo::Log) for more information.

Copyright (C) simbabque.
# METHODS

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
[Mojo::Log::Colored](https://metacpan.org/pod/Mojo::Log::Colored) inherits all methods from [Mojo::Log](https://metacpan.org/pod/Mojo::Log) and does not implement new ones.

# AUTHOR
# SEE ALSO

simbabque E<lt>simbabque@cpan.orgE<gt>
</div>
[Mojo::Log](https://metacpan.org/pod/Mojo::Log), [Term::ANSIColor](https://metacpan.org/pod/Term::ANSIColor)

# ACKNOWLEDGEMENTS

This plugin was inspired by lanti asking about a way to easier find specific errors
in the Mojo log during unit test runs on [Stack Overflow](https://stackoverflow.com/q/44965998/1331451).

# LICENSE

Copyright (C) simbabque.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

# AUTHOR

simbabque <simbabque@cpan.org>
7 changes: 7 additions & 0 deletions lib/Mojo/Log/Colored.pm
Expand Up @@ -40,10 +40,12 @@ __END__
Mojo::Log::Colored - Colored Mojo logging
=begin html
<p>
<a href="https://travis-ci.org/simbabque/Mojo-Log-Colored"><img src="https://travis-ci.org/simbabque/Mojo-Log-Colored.svg?branch=master"></a>
<a href='https://coveralls.io/github/simbabque/Mojo-Log-Colored?branch=master'><img src='https://coveralls.io/repos/github/simbabque/Mojo-Log-Colored/badge.svg?branch=master' alt='Coverage Status' /></a>
</p>
=end html
=head1 SYNOPSIS
Expand Down Expand Up @@ -109,6 +111,11 @@ L<Mojo::Log::Colored> inherits all methods from L<Mojo::Log> and does not implem
L<Mojo::Log>, L<Term::ANSIColor>
=head1 ACKNOWLEDGEMENTS
This plugin was inspired by lanti asking about a way to easier find specific errors
in the Mojo log during unit test runs on L<Stack Overflow|https://stackoverflow.com/q/44965998/1331451>.
=head1 LICENSE
Copyright (C) simbabque.
Expand Down

0 comments on commit caf8b02

Please sign in to comment.