From 7b5cc99c93fb0d2bcad43558bdb297846dfd03e8 Mon Sep 17 00:00:00 2001 From: stan Date: Fri, 16 Dec 2005 13:16:37 +0000 Subject: [PATCH] Bug 233 - Further debug enhancements git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1688 e3e1d417-86f3-4887-817a-d78f3d33393f --- scripts/ZoneMinder/lib/ZoneMinder.pm.in | 8 +++---- scripts/zmaudit.pl | 1 + scripts/zmcontrol-axis-v2.pl | 1 + scripts/zmcontrol-kx-hcm10.pl | 1 + scripts/zmcontrol-pelco-d.pl | 1 + scripts/zmcontrol-pelco-p.pl | 1 + scripts/zmcontrol-visca.pl | 1 + scripts/zmdc.pl | 28 +++++++++++++++---------- scripts/zmfilter.pl | 4 +++- scripts/zmpkg.pl | 1 + scripts/zmtrack.pl | 4 +++- scripts/zmtrigger.pl | 4 +++- scripts/zmupdate.pl | 4 +++- scripts/zmvideo.pl | 1 + scripts/zmwatch.pl | 3 ++- scripts/zmx10.pl | 2 ++ 16 files changed, 44 insertions(+), 21 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder.pm.in b/scripts/ZoneMinder/lib/ZoneMinder.pm.in index 6de5c0b3d..001051436 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder.pm.in @@ -94,8 +94,6 @@ BEGIN use POSIX; use Time::HiRes qw/gettimeofday/; -our $dbg_id = "zm"; - sub dbgPrint { my $code = shift; @@ -109,11 +107,11 @@ sub dbgPrint { my $file = __FILE__; $file =~ s|^.*/||g; - printf( STDERR "%s.%06d %s[%d].%s-%s/%d [%s]\n", strftime( "%x %H:%M:%S", localtime( $seconds ) ), $microseconds, $dbg_id, $$, $file, $line, $code, $string ); + printf( STDERR "%s.%06d %s[%d].%s-%s/%d [%s]\n", strftime( "%x %H:%M:%S", localtime( $seconds ) ), $microseconds, main::DBG_ID, $$, $file, $line, $code, $string ); } else { - printf( STDERR "%s.%06d %s[%d].%s [%s]\n", strftime( "%x %H:%M:%S", localtime( $seconds ) ), $microseconds, $dbg_id, $$, $code, $string ); + printf( STDERR "%s.%06d %s[%d].%s [%s]\n", strftime( "%x %H:%M:%S", localtime( $seconds ) ), $microseconds, main::DBG_ID, $$, $code, $string ); } } @@ -177,7 +175,7 @@ If you have a web site set up for your module, mention it here. =head1 AUTHOR -Philip Coombes, Estan@localdomainE +Philip Coombes, Ephilip.coombes@zoneminder.comE =head1 COPYRIGHT AND LICENSE diff --git a/scripts/zmaudit.pl b/scripts/zmaudit.pl index 0bec2ecd9..8ddadb23f 100644 --- a/scripts/zmaudit.pl +++ b/scripts/zmaudit.pl @@ -42,6 +42,7 @@ use constant MIN_AGE => 300; # Minimum age when we will delete anything use constant RECOVER_TAG => "(r)"; # Tag to append to event name when recovered use constant RECOVER_TEXT => "Recovered."; # Text to append to event notes when recovered +use constant DBG_ID => "zmaudit"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 1; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== diff --git a/scripts/zmcontrol-axis-v2.pl b/scripts/zmcontrol-axis-v2.pl index 28595f946..ce8a51925 100644 --- a/scripts/zmcontrol-axis-v2.pl +++ b/scripts/zmcontrol-axis-v2.pl @@ -33,6 +33,7 @@ use strict; # # ========================================================================== +use constant DBG_ID => "zmctrl-axis"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== diff --git a/scripts/zmcontrol-kx-hcm10.pl b/scripts/zmcontrol-kx-hcm10.pl index 554adf6ca..b05bfd71e 100644 --- a/scripts/zmcontrol-kx-hcm10.pl +++ b/scripts/zmcontrol-kx-hcm10.pl @@ -33,6 +33,7 @@ use strict; # # ========================================================================== +use constant DBG_ID => "zmctrl-pana"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== diff --git a/scripts/zmcontrol-pelco-d.pl b/scripts/zmcontrol-pelco-d.pl index fd79ee607..02fc15944 100644 --- a/scripts/zmcontrol-pelco-d.pl +++ b/scripts/zmcontrol-pelco-d.pl @@ -33,6 +33,7 @@ use strict; # # ========================================================================== +use constant DBG_ID => "zmctrl-peld"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== diff --git a/scripts/zmcontrol-pelco-p.pl b/scripts/zmcontrol-pelco-p.pl index 23e37fc67..6e484283f 100644 --- a/scripts/zmcontrol-pelco-p.pl +++ b/scripts/zmcontrol-pelco-p.pl @@ -33,6 +33,7 @@ use strict; # # ========================================================================== +use constant DBG_ID => "zmctrl-pelp"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== diff --git a/scripts/zmcontrol-visca.pl b/scripts/zmcontrol-visca.pl index d95dcd2a6..c22d38ea8 100644 --- a/scripts/zmcontrol-visca.pl +++ b/scripts/zmcontrol-visca.pl @@ -33,6 +33,7 @@ use strict; # # ========================================================================== +use constant DBG_ID => "zmctrl-visc"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== diff --git a/scripts/zmdc.pl b/scripts/zmdc.pl index 8d7c89968..1ecca1ace 100644 --- a/scripts/zmdc.pl +++ b/scripts/zmdc.pl @@ -36,9 +36,11 @@ use bytes; # # ========================================================================== -use constant MAX_CONNECT_DELAY => 10; +use constant DBG_ID => "zmdc"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug +use constant MAX_CONNECT_DELAY => 10; + # ========================================================================== # # Don't change anything from here on down @@ -334,18 +336,21 @@ if ( !connect( CLIENT, $saddr ) ) my $exit_signal = $status&0xfe; my $core_dumped = $status&0x01; + my $out_str = "'$process->{daemon} ".join( ' ', @{$process->{args}} )."' "; + $out_str .= ($exit_status==0)?"died":"crashed"; + $out_str .= ", exit status $exit_status" if ( $exit_status ); + $out_str .= ", signal $exit_signal" if ( $exit_signal ); + #print( ", core dumped" ) if ( $core_dumped ); + $out_str .= "\n"; + if ( $exit_status == 0 ) { - Info( "'$process->{daemon} ".join( ' ', @{$process->{args}} )."' died at ".strftime( '%y/%m/%d %H:%M:%S', localtime( $process->{stopped} ) ) ); + Info( $out_str ); } else { - Error( "'$process->{daemon} ".join( ' ', @{$process->{args}} )."' crashed at ".strftime( '%y/%m/%d %H:%M:%S', localtime( $process->{stopped} ) ) ); + Error( $out_str ); } - print( ", exit status $exit_status" ) if ( $exit_status ); - print( ", signal $exit_signal" ) if ( $exit_signal ); - #print( ", core dumped" ) if ( $core_dumped ); - print( "\n" ); if ( $process->{keepalive} ) { @@ -454,15 +459,16 @@ if ( !connect( CLIENT, $saddr ) ) return(); } } - dprint( "'$process->{command}' running at ".strftime( '%y/%m/%d %H:%M:%S', localtime( $process->{started}) ).", pid = $process->{pid}" ); + dprint( "'$process->{command}' running since ".strftime( '%y/%m/%d %H:%M:%S', localtime( $process->{started}) ).", pid = $process->{pid}" ); } else { foreach my $process ( values(%pid_hash) ) { - dprint( "'$process->{command}' running at ".strftime( '%y/%m/%d %H:%M:%S', localtime( $process->{started}) ).", pid = $process->{pid}" ); - dprint( ", valid" ) if ( kill( 0, $process->{pid} ) ); - dprint( "\n" ); + my $out_str = "'$process->{command}' running since ".strftime( '%y/%m/%d %H:%M:%S', localtime( $process->{started}) ).", pid = $process->{pid}"; + $out_str .= ", valid" if ( kill( 0, $process->{pid} ) ); + $out_str .= "\n"; + dprint( $out_str ); } foreach my $process ( values( %cmd_hash ) ) { diff --git a/scripts/zmfilter.pl b/scripts/zmfilter.pl index 4c317fd9d..6865f54da 100644 --- a/scripts/zmfilter.pl +++ b/scripts/zmfilter.pl @@ -34,9 +34,11 @@ use bytes; # # ========================================================================== -use constant START_DELAY => 5; # How long to wait before starting +use constant DBG_ID => "zmfilter"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug +use constant START_DELAY => 5; # How long to wait before starting + # ========================================================================== # # You shouldn't need to change anything from here downwards diff --git a/scripts/zmpkg.pl b/scripts/zmpkg.pl index e6ac80673..77eae021e 100644 --- a/scripts/zmpkg.pl +++ b/scripts/zmpkg.pl @@ -33,6 +33,7 @@ use bytes; # # ========================================================================== +use constant DBG_ID => "zmpkg"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== diff --git a/scripts/zmtrack.pl b/scripts/zmtrack.pl index 398fe349f..f88ea5a9a 100644 --- a/scripts/zmtrack.pl +++ b/scripts/zmtrack.pl @@ -33,9 +33,11 @@ use bytes; # # ========================================================================== -use constant SLEEP_TIME => 10000; # In microseconds +use constant DBG_ID => "zmtrack"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 1; # 0 is errors, warnings and info only, > 0 for debug +use constant SLEEP_TIME => 10000; # In microseconds + # ========================================================================== # # Don't change anything from here on down diff --git a/scripts/zmtrigger.pl b/scripts/zmtrigger.pl index 16b5b9cac..08342759f 100644 --- a/scripts/zmtrigger.pl +++ b/scripts/zmtrigger.pl @@ -33,9 +33,11 @@ use bytes; # # ========================================================================== -use constant MAX_CONNECT_DELAY => 10; +use constant DBG_ID => "zmtrigger"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug +use constant MAX_CONNECT_DELAY => 10; + # Now define the trigger sources, can be inet socket, unix socket or file based # Ignore parser field for now. diff --git a/scripts/zmupdate.pl b/scripts/zmupdate.pl index e53071f6a..22b28220b 100644 --- a/scripts/zmupdate.pl +++ b/scripts/zmupdate.pl @@ -34,9 +34,11 @@ use bytes; # # ========================================================================== -use constant CHECK_INTERVAL => (1*24*60*60); # Interval between version checks +use constant DBG_ID => "zmupdate"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug +use constant CHECK_INTERVAL => (1*24*60*60); # Interval between version checks + # ========================================================================== # # Don't change anything below here diff --git a/scripts/zmvideo.pl b/scripts/zmvideo.pl index 8893908ef..380766bb0 100644 --- a/scripts/zmvideo.pl +++ b/scripts/zmvideo.pl @@ -33,6 +33,7 @@ use bytes; # # ========================================================================== +use constant DBG_ID => "zmvideo"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== diff --git a/scripts/zmwatch.pl b/scripts/zmwatch.pl index ec4dcb8ed..68622b292 100644 --- a/scripts/zmwatch.pl +++ b/scripts/zmwatch.pl @@ -34,9 +34,10 @@ use bytes; # # ========================================================================== -use constant START_DELAY => 30; # To give everything else time to start +use constant DBG_ID => "zmwatch"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug +use constant START_DELAY => 30; # To give everything else time to start # ========================================================================== # diff --git a/scripts/zmx10.pl b/scripts/zmx10.pl index 126570df1..84fb89c49 100644 --- a/scripts/zmx10.pl +++ b/scripts/zmx10.pl @@ -33,6 +33,7 @@ use bytes; # # ========================================================================== +use constant DBG_ID => "zmx10"; # Tag that appears in debug to identify source use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== @@ -140,6 +141,7 @@ package X10Server; use strict; use bytes; +use ZoneMinder; use POSIX; use DBI; use Socket;