| 1 | package Dancer2::Logger::Multiplex; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use 5.008_005; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | our $VERSION = '0.02'; | |
| 6 | |||
| 7 | 2 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 2 | ▶ | use Dancer2::Core::Types; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 2 | with 'Dancer2::Core::Role::Logger'; | |
| 10 | |||
| 11 | 2 | has loggers => ( | |
| 12 | is => 'ro', | ||
| 13 | isa => ArrayRef, | ||
| 14 | ); | ||
| 15 | |||
| 16 | 2 | has logging_engines => ( | |
| 17 | is => 'lazy', | ||
| 18 | ); | ||
| 19 | |||
| 20 | 0 | ▶ | sub _build_logging_engines { |
|
Subroutine
_build_logging_engines: not called CC=1 SCAR=6.9
| |||
| 21 | 0 | my $self = shift; | |
| 22 | |||
| 23 | 0 | my ($app) = grep { $_->name eq $self->app_name } @{ $Dancer2::runner->apps }; | |
| 24 | |||
| 25 | my @logging_engines = map { | ||
| 26 | $app->_factory->create( | ||
| 27 | logger => $_, | ||
| 28 | 0 | %{ $app->_get_config_for_engine( logger => $_, $app->config ) }, | |
| 29 | location => $app->config_location, | ||
| 30 | environment => $app->environment, | ||
| 31 | app_name => $app->name, | ||
| 32 | postponed_hooks => $app->postponed_hooks | ||
| 33 | ) | ||
| 34 | 0 | } @{ $self->loggers }; | |
| 35 | |||
| 36 | 0 | return \@logging_engines; | |
| 37 | } | ||
| 38 | |||
| 39 | sub log { | ||
| 40 | my ($self, $level, $message) = @_; | ||
| 41 | $_->log($level, $message) for @{ $self->logging_engines }; | ||
| 42 | } | ||
| 43 | |||
| 44 | 2 | 1; | |
| 45 | __END__ | ||