MooseX::Types::Log::Dispatch - Log::Dispatch related constraints and coercions for Moose
package MyFoo; use MooseX::Types::Log::Dispatch qw(Logger LogLevel); has logger => ( isa => Logger, is => 'ro', coerce => 1, ); has event_log_level => ( isa => LogLevel, is => 'ro', ); sub some_event_happened { my ($self, $event) = @_; $self->logger->log( level => $self->event_log_level, message => "$event happened"); } my $obj1 = MyFoos->new( event_log_level => 'debug', logger => [ ['Screen', min_level => 'notice' ] ] ); ## or my $obj2 = MyFoos->new( event_log_level => 'warning', logger => { outputs => [ ['Screen', min_level => 'debug' ] ] } ); $obj1->some_event_happened('zoom'); #nothing prints $obj2->some_event_happened('zoom'); # 'zoom happened' prints
This module provides Moose TypeConstraints that are believed to be useful when working with Log::Dispatch;
Class type for 'Log::Dispatch' optional coercion will turn dereference a hash reference and pass it to 'new' or treat an array reference as a list of outputs.
outputs
A subtype of 'Str', this should be a string that is a valid Log::Dispatch log level like: 0, 1, 2 ,3 ,4 ,5 ,6 ,7, info, debug, notice, warn, warning, err, error, crit, critical, alert, emerg, and emergency
Guillermo Roditi (groditi) <groditi@cpan.org>
Copyright (c) 2010 Guillermo Roditi. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MooseX::Types::Log::Dispatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Types::Log::Dispatch
CPAN shell
perl -MCPAN -e shell install MooseX::Types::Log::Dispatch
For more information on module installation, please visit the detailed CPAN module installation guide.