Implement debug levels in perl side. DEBUG==DEBUG1.

This commit is contained in:
Isaac Connor 2021-04-10 15:35:04 -04:00
parent 3f05cfadb0
commit 60970673c7
1 changed files with 41 additions and 18 deletions

View File

@ -42,6 +42,15 @@ our @ISA = qw(Exporter ZoneMinder::Base);
# will save memory.
our %EXPORT_TAGS = (
constants => [ qw(
DEBUG9
DEBUG8
DEBUG7
DEBUG6
DEBUG5
DEBUG4
DEBUG3
DEBUG2
DEBUG1
DEBUG
INFO
WARNING
@ -98,6 +107,15 @@ use Time::HiRes qw/gettimeofday/;
use Sys::Syslog;
use constant {
DEBUG9 => 9,
DEBUG8 => 8,
DEBUG7 => 7,
DEBUG6 => 6,
DEBUG5 => 5,
DEBUG4 => 4,
DEBUG3 => 3,
DEBUG2 => 2,
DEBUG1 => 1,
DEBUG => 1,
INFO => 0,
WARNING => -1,
@ -108,7 +126,16 @@ use constant {
};
our %codes = (
&DEBUG => 'DBG',
&DEBUG9 => 'DB9',
&DEBUG8 => 'DB8',
&DEBUG7 => 'DB7',
&DEBUG6 => 'DB6',
&DEBUG5 => 'DB5',
&DEBUG4 => 'DB4',
&DEBUG3 => 'DB3',
&DEBUG2 => 'DB2',
&DEBUG1 => 'DB1',
&DEBUG => 'DB1',
&INFO => 'INF',
&WARNING => 'WAR',
&ERROR => 'ERR',
@ -332,9 +359,9 @@ sub reinitialise {
sub limit {
my $this = shift;
my $level = shift;
return(DEBUG) if $level > DEBUG;
return(NOLOG) if $level < NOLOG;
return($level);
return DEBUG9 if $level > DEBUG9;
return NOLOG if $level < NOLOG;
return $level;
}
sub getTargettedEnv {
@ -689,38 +716,34 @@ sub Dump {
sub debug {
my $log = shift;
$log->logPrint(DEBUG, @_, caller);
$log->logPrint(DEBUG1, @_, caller);
}
sub Debug( @ ) {
fetch()->logPrint(DEBUG, @_, caller);
sub Debug {
fetch()->logPrint(
(@_ == 1 ? (DEBUG1, @_) : @_),
caller);
}
sub Info( @ ) {
fetch()->logPrint(INFO, @_, caller);
}
sub Info { fetch()->logPrint(INFO, @_, caller); }
sub info {
my $log = shift;
$log->logPrint(INFO, @_, caller);
}
sub Warning( @ ) {
fetch()->logPrint(WARNING, @_, caller);
}
sub Warning { fetch()->logPrint(WARNING, @_, caller); }
sub warn {
my $log = shift;
$log->logPrint(WARNING, @_, caller);
}
sub Error( @ ) {
fetch()->logPrint(ERROR, @_, caller);
}
sub Error { fetch()->logPrint(ERROR, @_, caller); }
sub error {
my $log = shift;
$log->logPrint(ERROR, @_, caller);
}
sub Fatal( @ ) {
sub Fatal {
my $this = fetch();
$this->logPrint(FATAL, @_, caller);
if ( $SIG{TERM} and ( $SIG{TERM} ne 'DEFAULT' ) ) {
@ -735,7 +758,7 @@ sub Fatal( @ ) {
exit(-1);
}
sub Panic( @ ) {
sub Panic {
fetch()->logPrint(PANIC, @_, caller);
confess($_[0]);
}