Доброго всем

Mojo::Log::Che

¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !

VERSION

0.07

NAME

Mojo::Log::Che - Little child of great parent Mojo::Log.

SYNOPSIS

Parent Mojo::Log behavior just works

use Mojo::Log::Che;
my $log = Mojo::Log::Log->new(path => '/var/log/mojo.log', level => 'warn');
$log->debug(...);

EXTENDED THINGS

# Set "path" to folder + have default "paths" for levels (be sure that mkdir /var/log/mojo)
my $log = Mojo::Log::Log->new(path => '/var/log/mojo'); 
$log->warn(...);# log to  /var/log/mojo/warn.log
$log->error(...); # log to  /var/log/mojo/error.log
$log->foo(...);# log to  /var/log/mojo/foo.log

# set "path" to folder + set custom relative "paths" (be sure that mkdir /var/log/mojo)
my $log = Mojo::Log::Log->new(path => '/var/log/mojo', paths=>{debug=>'dbg.log', foo=>'myfoo.log'});
$log->debug(...); # log to  /var/log/mojo/dbg.log
$log->warn(...);# log to /var/log/mojo/warn.log
$log->foo(...);# log to  /var/log/mojo/myfoo.log

# set "path" to file + have default "paths" for levels
# this is standard Mojo::Log behavior + custom level/method also
my $log = Mojo::Log::Log->new(path => '/var/log/mojo.log');
$log->debug(...); # log to  /var/log/mojo.log
$log->warn(...);# log to  /var/log/mojo.log
$log->foo(...);# log to /var/log/mojo.log

# set "path" to file + set custom absolute "paths"
my $log = Mojo::Log::Log->new(path => '/var/log/mojo.log', paths => {error=>'/var/log/mojo.error.log'});
$log->debug(...); # log to  /var/log/mojo.log
$log->foo(...);# log to /var/log/mojo.log
$log->error(...);  # log to /var/log/mojo.error.log

# Log to STDERR + set custom absolute "paths"
$log->path(undef); # none path
$log->level('info');
$log->paths->{'error'} = '/var/log/error.log'; # absolute file only for error level
$log->error(...);  # log to /var/log/error.log
$log->info(...); # log to STDERR
$log->debug(...); # no log
$log->foo(...); # anyway log to STDERR

DESCRIPTION

This Mojo::Log::Che is a extended logger module for Mojo projects.

EVENTS

Mojo::Log::Che inherits all events from Mojo::Log and override following ones.

message

See also parent "message" in Mojo::Log. Extends parent module logics for switching handlers.

ATTRIBUTES

Mojo::Log::Che inherits all attributes from "Mojo::Log and implements the following new ones."

handlers

Hashref of created file handlers for standard and custom levels. For standard parent Mojo::Log logic none handlers but "handle" in Mojo::Log will be in the scene.

$log->handlers->{'foo'} = IO::Handle->new();

path

See parent "path" in Mojo::Log. Can set to folder and file path.

paths

Hashref map level names to absolute or relative to "path"

$log->path('/var/log'); # folder relative
$log->paths->{'error'} = 'err.log';
$log->error(...);#  /var/log/err.log
$log->info(...); # log to filename as level name /var/log/info.log

$log->path(undef); # none 
$log->paths->{'error'} = '/var/log/error.log'; # absolute path only error level
$log->error(...); # log to /var/log/error.log
$log->info(...); # log to STDERR

trace

An trace level, defaults to 4, 0 value will disable trace log. This value pass to caller().

METHODS

Mojo::Log::Che inherits all methods from Mojo::Log and implements the following new ones.

handler($level)

Return undef when "path" undefined or "path" is file or has not defined "paths" for $level. In this case "handle" in Mojo::Log will return default handler.

Return file handler overwise.

AUTOLOAD

Autoloads nonstandard/custom levels excepts already defined keywords of this and parent modules Mojo::Log, Mojo::EventEmitter, Mojo::Base:

qw(message _message format _format handle handler handlers
history level max_history_size  path paths append debug  error fatal info
is_level  new warn  catch emit  has_subscribers on  once subscribers unsubscribe
has  attr tap _monkey_patch import)

and maybe anymore!

$log->foo('bar here');

That custom levels log always without reducing log output outside of level.

SEE ALSO

Mojo::Log, Mojolicious, Mojolicious::Guides, http://mojolicious.org.

AUTHOR

Михаил Че (Mikhail Che), <mche[-at-]cpan.org>

BUGS / CONTRIBUTING

Please report any bugs or feature requests at https://github.com/mche/Mojo-Log-Che/issues. Pull requests also welcome.

COPYRIGHT

Copyright 2017 Mikhail Che.

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 213:

Unterminated L<...> sequence