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

26 lines
533 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;
2019-02-12 18:21:38 +01:00
our $VERSION = '2.1.0';
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;
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
}
2017-02-12 21:19:39 +01:00
die "unknown level $level" if ($show);
2017-02-13 12:58:39 +01:00
return bless {}, shift;
2017-02-12 21:09:46 +01:00
}
1;