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

26 lines
533 B
Perl

package Lemonldap::NG::Common::Logger::Std;
use strict;
our $VERSION = '2.1.0';
sub new {
no warnings 'redefine';
my $level = $_[1]->{logLevel} || 'info';
my $show = 1;
foreach (qw(error warn notice info debug)) {
if ($show) {
eval
qq'sub $_ {print STDERR "[".localtime."] [LLNG:\$\$] [$_] \$_[1]\n"}';
}
else {
eval qq'sub $_ {1}';
}
$show = 0 if ( $level eq $_ );
}
die "unknown level $level" if ($show);
return bless {}, shift;
}
1;