mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +00:00
fhem.pl: add stacktrace for warnging. By Dietmar63, modified. (Forum #27471)
git-svn-id: https://svn.fhem.de/fhem/trunk@6684 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
bb02dcb0bd
commit
abf8df9af1
39
fhem/fhem.pl
39
fhem/fhem.pl
@ -2553,7 +2553,6 @@ InternalTimer($$$$)
|
||||
$nextat = $tim if(!$nextat || $nextat > $tim);
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
RemoveInternalTimer($)
|
||||
{
|
||||
@ -2564,20 +2563,46 @@ RemoveInternalTimer($)
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
stacktrace() {
|
||||
|
||||
my $i = 1;
|
||||
my $max_depth = 50;
|
||||
|
||||
Log 3, "stacktrace:";
|
||||
while( (my @call_details = (caller($i++))) && ($i<$max_depth) ) {
|
||||
Log 3, sprintf (" %-35s called by %s (%s)",
|
||||
$call_details[3], $call_details[1], $call_details[2]);
|
||||
}
|
||||
}
|
||||
|
||||
my $inWarnSub;
|
||||
|
||||
sub
|
||||
SignalHandling()
|
||||
{
|
||||
if($^O ne "MSWin32") {
|
||||
$SIG{'INT'} = sub { $sig_term = 1; };
|
||||
$SIG{'TERM'} = sub { $sig_term = 1; };
|
||||
$SIG{'PIPE'} = 'IGNORE';
|
||||
$SIG{'CHLD'} = 'IGNORE';
|
||||
$SIG{'HUP'} = sub { CommandRereadCfg(undef, "") };
|
||||
$SIG{'ALRM'} = sub { Log 1, "ALARM signal, blocking write?" };
|
||||
$SIG{INT} = sub { $sig_term = 1; };
|
||||
$SIG{TERM} = sub { $sig_term = 1; };
|
||||
$SIG{PIPE} = 'IGNORE';
|
||||
$SIG{CHLD} = 'IGNORE';
|
||||
$SIG{HUP} = sub { CommandRereadCfg(undef, "") };
|
||||
$SIG{ALRM} = sub { Log 1, "ALARM signal, blocking write?" };
|
||||
#$SIG{'XFSZ'} = sub { Log 1, "XFSZ signal" }; # to test with limit filesize
|
||||
}
|
||||
$SIG{__WARN__} = sub {
|
||||
my ($msg) = @_;
|
||||
|
||||
return if($inWarnSub);
|
||||
$inWarnSub = 1;
|
||||
chomp($msg);
|
||||
Log 1, "PERL WARNING: $msg";
|
||||
stacktrace() if($attr{global}{verbose} >= 3 && $msg !~ m/ redefined at /);
|
||||
$inWarnSub = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#####################################
|
||||
sub
|
||||
TimeNow()
|
||||
|
Loading…
x
Reference in New Issue
Block a user