NAME
MooseX::Types::Log::Dispatch - Log::Dispatch related constraints and coercions for Moose
SYNOPSIS
package
MyFoo;
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
DESCRIPTION
This module provides Moose TypeConstraints that are believed to be useful when working with Log::Dispatch;
AVAILABLE CONSTRAINTS
Logger
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
.
LogLevel
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
AUTHOR
Guillermo Roditi (groditi) <groditi@cpan.org>
COPYRIGHT AND LICENSE
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.