| 1 | package Log::Any::Adapter::Catalyst; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Enable error and status logging in Catalyst Models via Log::Any | ||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Log::Any::Adapter::Util qw(make_method); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use base qw(Log::Any::Adapter::Base); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | our $VERSION = '1.00'; | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||
| 14 | 1 | my ($self) = @_; | |||||||||
| 15 | |||||||||||
| 16 | croak "Log::Any::Adapter->set must be called with the 'logger' parameter\n" | ||||||||||
| 17 | . "Typically, in you Catalyst Application Class:\n" | ||||||||||
| 18 | . "Log::Any::Adapter->set('Catalyst', logger => __PACKAGE__->log);\n" | ||||||||||
| 19 | 1 | ▶ | unless $self->{logger}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | # Connect the Log::Any methods to the appropriate Catalyst::Log method | ||||||||||
| 23 | 2 | foreach my $method ( Log::Any->logging_and_detection_methods() ) { | |||||||||
| 24 | 36 | my $cat_log_method = $method; | |||||||||
| 25 | |||||||||||
| 26 | # Map log levels down to Catalyst::Log levels where necessary | ||||||||||
| 27 | 36 | for ($cat_log_method) { | |||||||||
| 28 | 36 | s/trace/debug/; | |||||||||
| 29 | 36 | s/notice/info/; | |||||||||
| 30 | 36 | s/warning/warn/; | |||||||||
| 31 | 36 | s/critical|alert|emergency/fatal/; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 36 | __PACKAGE__->delegate_method_to_slot( 'logger', $method, $cat_log_method ); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 2 | 1; | |||||||||
| 38 | |||||||||||
| 39 | __END__ | ||||||||||