The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MouseX::Log::Dispatch::Config - A Mouse role for logging

SYNOPSIS

    package MyLogger;
    use Mouse;
    with 'MouseX::Log::Dispatch::Config';

    package main;

    # file-based (AppConfig style)
    my $log = MyLogger->new(config => '/path/to/log.cfg');

    # hash-based
    my $log = MyLogger->new(config => {
        class     => 'Log::Dispatch::Screen',
        min_level => 'debug',
        stderr    => 1,
        format    => '[%p] %m at %F line %L%n',
    });

    # custom configurator
    my $log = MyLogger->new(
        config => Log::Dispatch::Configurator::YAML->new('/path/to/log.yml')
    );

    $log->debug('foo');
    $log->logger->debug('bar'); # also works

    $log->info('baz');
    $log->error('error');

DESCRIPTION

This is a role which provides a Log::Dispatch::Config logger.

METHODS

new(config => $config)

This method accepts logger config which is Str, HashRef and Log::Dispatch::Configurator object.

Coerces from Str and HashRef via MouseX::Types::Log::Dispatch::Configurator.

log

debug

info

notice

warning

error

critical

alert

emergency

PROPERTIES

logger

Returns a Log::Dispatch::Config object.

AUTHOR

NAKAGAWA Masaki <masaki@cpan.org>

THANKS TO

Ash Berlin, and "AUTHOR" in MooseX::LogDispatch

LICENSE

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

SEE ALSO

Mouse, Mouse::Role, MouseX::Types::Log::Dispatch::Configurator,

Log::Dispatch::Config, Log::Dispatch::Configurator, Log::Dispatch,

MooseX::LogDispatch