2017-02-12 21:09:46 +01:00
|
|
|
package Lemonldap::NG::Common::Logger::Std;
|
|
|
|
|
2017-02-13 17:48:39 +01:00
|
|
|
use strict;
|
|
|
|
|
2017-02-28 21:53:19 +01:00
|
|
|
our $VERSION = '2.0.0';
|
|
|
|
|
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';
|
2017-02-12 21:09:46 +01:00
|
|
|
my $show = 1;
|
2017-02-12 21:19:39 +01:00
|
|
|
foreach (qw(error warn notice info debug)) {
|
|
|
|
if ($show) {
|
2017-02-12 21:09:46 +01:00
|
|
|
eval qq'sub $_ {print STDERR "[$_] \$_[1]\n"}';
|
|
|
|
}
|
|
|
|
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;
|