Debian Codegraph @

lemonldap-ng-common/lib/Lemonldap/NG/Common/Logger/_Duplicate.pm

raw
1 package Lemonldap::NG::Common::Logger::_Duplicate;
2
3 use strict;
4
5 our $VERSION = '2.23.0';
6
7 sub new {
8 my $self = bless {}, shift;
9 my ( $conf, %args ) = @_;
10 eval "require $args{logger}";
11 die $@ if ($@);
12 $self->{logger} = $args{logger}->new(@_);
13 $self->{dup} = $args{dup} or die 'Missing dup';
14 return $self;
15 }
16
17 sub setRequestObj {
18 my $self = shift;
19 if ( $self->{logger}->can('setRequestObj') ) {
20 return $self->{logger}->setRequestObj(@_);
21 }
22 return;
23 }
24
25 sub clearRequestObj {
26 my $self = shift;
27 if ( $self->{logger}->can('clearRequestObj') ) {
28 return $self->{logger}->clearRequestObj(@_);
29 }
30 return;
31 }
32
33 sub AUTOLOAD {
34 my $self = shift;
35 no strict;
36 $AUTOLOAD =~ s/.*:://;
37 return if $AUTOLOAD eq 'DESTROY';
38 $self->{logger}->$AUTOLOAD(@_);
39 return if $AUTOLOAD !~ m/^(?:error|warn|notice|info|debug)$/;
40 my $msg = shift;
41 $msg = "[$AUTOLOAD] $msg";
42 $self->{dup}->debug( $msg, @_ );
43 }
44
45 1;