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

28 lines
537 B
Perl
Raw Normal View History

2017-02-12 21:09:46 +01:00
package Lemonldap::NG::Common::Logger::Std;
2017-02-13 17:48:39 +01:00
use strict;
2022-07-28 12:42:15 +02:00
our $VERSION = '2.0.15';
2017-02-28 21:53:19 +01:00
2017-02-13 12:58:39 +01:00
sub new {
2017-02-12 21:09:46 +01:00
no warnings 'redefine';
2017-02-12 21:19:39 +01:00
my $level = $_[1]->{logLevel} || 'info';
2019-07-02 20:03:40 +02:00
my $show = 1;
2022-06-20 00:10:57 +02:00
2017-02-12 21:19:39 +01:00
foreach (qw(error warn notice info debug)) {
if ($show) {
2019-05-16 20:42:31 +02:00
eval
qq'sub $_ {print STDERR "[".localtime."] [LLNG:\$\$] [$_] \$_[1]\n"}';
2017-02-12 21:09:46 +01:00
}
else {
eval qq'sub $_ {1}';
}
2017-02-12 21:19:39 +01:00
$show = 0 if ( $level eq $_ );
2017-02-12 21:09:46 +01:00
}
2022-06-20 00:10:57 +02:00
die "Unknown logLevel $level" if $show;
2017-02-13 12:58:39 +01:00
return bless {}, shift;
2017-02-12 21:09:46 +01:00
}
1;