Log-Levels trace debug info (inform) notice warning (warn) error (err) critical (crit, fatal) alert emergency

NAME

Siffra::Logger - Siffra config for Log::Any

SYNOPSIS

In a CPAN or other module:

    package Foo;
    use Log::Any qw($log);
    use Siffra::Logger;

    # log a string
    $log->error("an error occurred");

    # log a string and some data
    $log->info("program started", {progname => $0, pid => $$, perl_version => $]});

    # log a string and data using a format string
    $log->debugf("arguments are: %s", \@_);

    # log an error and throw an exception
    die $log->fatal("a fatal error occurred");

In your application:

    use Foo;
    use Log::Any qw($log);
    use Siffra::Logger;

    # log a string
    $log->error("an error occurred");

    # log a string and some data
    $log->info("program started", {progname => $0, pid => $$, perl_version => $]});

    # log a string and data using a format string
    $log->debugf("arguments are: %s", \@_);

    # log an error and throw an exception
    die $log->fatal("a fatal error occurred");

OUTPUTS

Directory Creation
    my ( $filename, $baseDirectory, $suffix ) = fileparse( $0, qr/\.[^.]*/ );
    my $logDirectory = $baseDirectory . 'logs/';
    my $logFilename  = $filename . '.log';
    croak( "Unable to create $logDirectory" ) unless ( -e $logDirectory or mkdir $logDirectory );
Outputs
    [
        'Screen',
        name      => 'screen',
        min_level => 'debug',
        max_level => 'warning',
        newline   => 1,
        utf8      => 0,
        stderr    => 0,
        use_color => 1,
    ],
    [
        'Screen',
        name      => 'screen-error',
        min_level => 'error',
        newline   => 1,
        utf8      => 0,
        stderr    => 1,
        use_color => 1,
    ],
    [
        'File',
        name      => 'file-01',
        filename  => $logDirectory . $logFilename,
        min_level => 'debug',
        newline   => 1,
        mode      => 'write',
        binmode   => ':encoding(UTF-8)',
    ]

DESCRIPTION

Siffra::logger provides a standart outputs to Log::Any

AUTHOR

    Luiz Benevenuto
    CPAN ID: LUIZBENE
    Siffra TI
    luiz@siffra.com.br
    https://siffra.com.br

COPYRIGHT

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

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

perl(1).