| 1 | package MooseX::LogDispatch::Levels; | ||
| 2 | |||
| 3 | 3 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use MooseX::LogDispatch::Interface; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | # Ideally i would like to be able to do | ||
| 7 | # | ||
| 8 | 3 | with 'MooseX::LogDispatch'; | |
| 9 | #has '+logger' => ( handles => 'MooseX::LogDispatch::Interface' ); | ||
| 10 | # | ||
| 11 | # but it doesn't work because roles don't handle +attr | ||
| 12 | |||
| 13 | # nor do they handle 'extends' which fucks up the OTHER approach | ||
| 14 | |||
| 15 | # the dirty trick of has _logger => ( | ||
| 16 | # default => sub { shift->logger } | ||
| 17 | # handles => .... | ||
| 18 | # ) | ||
| 19 | # also doesn't work because you can't massage the CallerDepth! | ||
| 20 | |||
| 21 | # We could probably do this in some really sick way using autobox | ||
| 22 | # and ->curry, but life's too short. | ||
| 23 | |||
| 24 | 6 | ▶ | sub _handle_log { |
|
Subroutine
_handle_log: called CC=1 SCAR=0.0
| |||
| 25 | 6 | my ($self, $level, @args) = @_; | |
| 26 | 6 | local $Log::Dispatch::Config::CallerDepth = $Log::Dispatch::Config::CallerDepth + 2; | |
| 27 | 6 | $self->logger->$level(@args); | |
| 28 | } | ||
| 29 | |||
| 30 | 0 | ▶ | sub log { shift->_handle_log('log',@_) } |
|
Subroutine
log: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 31 | 2 | ▶ | sub debug { shift->_handle_log('debug', @_) } |
|
Subroutine
debug: called CC=1 SCAR=0.0
Pod
documented
| |||
| 32 | 2 | ▶ | sub info { shift->_handle_log('info',@_) } |
|
Subroutine
info: called CC=1 SCAR=0.0
Pod
documented
| |||
| 33 | 0 | ▶ | sub notice { shift->_handle_log('notice',@_) } |
|
Subroutine
notice: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 34 | 0 | ▶ | sub warning { shift->_handle_log('warning',@_) } |
|
Subroutine
warning: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 35 | 2 | ▶ | sub error { shift->_handle_log('error',@_) } |
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||
| 36 | 0 | ▶ | sub critical { shift->_handle_log('critical',@_) } |
|
Subroutine
critical: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 37 | 0 | ▶ | sub alert { shift->_handle_log('alert',@_) } |
|
Subroutine
alert: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 38 | 0 | ▶ | sub emergency { shift->_handle_log('emergency',@_) } |
|
Subroutine
emergency: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 39 | |||
| 40 | 3 | ▶ | no Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 41 | 3 | 1; # need the magic smoke | |
| 42 | __END__ | ||