Debian Codegraph @

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

raw
1 package Lemonldap::NG::Common::Logger::Std;
2
3 use strict;
4
5 our $VERSION = '2.0.15';
6
7 sub new {
8 no warnings 'redefine';
9 my $level = $_[1]->{logLevel} || 'info';
10 my $show = 1;
11
12 foreach (qw(error warn notice info debug)) {
13 if ($show) {
14 eval
15 qq'sub $_ {print STDERR "[".localtime."] [LLNG:\$\$] [$_] \$_[1]\n"}';
16 }
17 else {
18 eval qq'sub $_ {1}';
19 }
20 $show = 0 if ( $level eq $_ );
21 }
22 die "Unknown logLevel $level" if $show;
23
24 return bless {}, shift;
25 }
26
27 1;