From 948528bb44ee3ac2a121054d5770f04c1028fbe2 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 20 Dec 2005 17:03:33 +0000 Subject: [PATCH] Changed debug to not use constants. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1704 e3e1d417-86f3-4887-817a-d78f3d33393f --- scripts/ZoneMinder/lib/ZoneMinder/Debug.pm | 10 ++------ scripts/zmaudit.pl | 28 +--------------------- scripts/zmcontrol-axis-v2.pl | 2 ++ scripts/zmcontrol-kx-hcm10.pl | 2 ++ scripts/zmcontrol-pelco-d.pl | 2 ++ scripts/zmcontrol-pelco-p.pl | 2 ++ scripts/zmcontrol-visca.pl | 2 ++ scripts/zmdc.pl | 2 ++ scripts/zmfilter.pl | 2 ++ scripts/zmpkg.pl | 2 ++ scripts/zmtrack.pl | 2 ++ scripts/zmtrigger.pl | 2 ++ scripts/zmupdate.pl | 2 ++ scripts/zmvideo.pl | 2 ++ scripts/zmwatch.pl | 2 ++ scripts/zmx10.pl | 2 ++ 16 files changed, 31 insertions(+), 35 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Debug.pm b/scripts/ZoneMinder/lib/ZoneMinder/Debug.pm index f2a1cf551..e2f9170e5 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Debug.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Debug.pm @@ -47,6 +47,7 @@ our %EXPORT_TAGS = ( 'all' => [ qw( our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( + zmDbgInit Debug Info Warning @@ -82,20 +83,13 @@ sub zmDbgInit { $dbg_id = $id; } - else - { - $dbg_id = main::DBG_ID; - } if ( defined($level) ) { $dbg_level = $level; } - else - { - $dbg_level = main::DBG_LEVEL; - } openlog( $dbg_id, "pid,ndelay", "local1" ); + $dbg_initialised = !undef; } diff --git a/scripts/zmaudit.pl b/scripts/zmaudit.pl index 8ddadb23f..6c2ccc2b8 100644 --- a/scripts/zmaudit.pl +++ b/scripts/zmaudit.pl @@ -83,32 +83,6 @@ Parameters are :- exit( -1 ); } -my $dbg_id = ""; - -sub dbgInit -{ - my $id = shift; - if ( $id ) - { - $dbg_id = $id; - my $add_parms = shift; - if ( $add_parms ) - { - foreach my $arg ( @ARGV ) - { - if ( $arg =~ /^-(.*)$/ ) - { - $dbg_id .= "_$1"; - } - else - { - $dbg_id .= $arg; - } - } - } - } -} - sub aud_print { my $string = shift; @@ -169,7 +143,7 @@ sub confirm return( $yesno ); } -dbgInit( "zmaudit", 1 ); +zmDbgInit( DBG_ID, DBG_LEVEL ); if ( !GetOptions( 'report'=>\$report, 'yes'=>\$yes, 'delay=i'=>\$delay ) ) { diff --git a/scripts/zmcontrol-axis-v2.pl b/scripts/zmcontrol-axis-v2.pl index ce8a51925..9592b4c0a 100644 --- a/scripts/zmcontrol-axis-v2.pl +++ b/scripts/zmcontrol-axis-v2.pl @@ -58,6 +58,8 @@ Usage: zmcontrol-axis-v2.pl exit( -1 ); } +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $arg_string = join( " ", @ARGV ); my $address; diff --git a/scripts/zmcontrol-kx-hcm10.pl b/scripts/zmcontrol-kx-hcm10.pl index b05bfd71e..d9d28119f 100644 --- a/scripts/zmcontrol-kx-hcm10.pl +++ b/scripts/zmcontrol-kx-hcm10.pl @@ -58,6 +58,8 @@ Usage: zmcontrol-kx-hcm10.pl exit( -1 ); } +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $arg_string = join( " ", @ARGV ); my $address; diff --git a/scripts/zmcontrol-pelco-d.pl b/scripts/zmcontrol-pelco-d.pl index 02fc15944..5361cbf9d 100644 --- a/scripts/zmcontrol-pelco-d.pl +++ b/scripts/zmcontrol-pelco-d.pl @@ -59,6 +59,8 @@ Usage: zmcontrol-pelco-d.pl exit( -1 ); } +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $arg_string = join( " ", @ARGV ); my $device = "/dev/ttyS0"; diff --git a/scripts/zmcontrol-pelco-p.pl b/scripts/zmcontrol-pelco-p.pl index 6e484283f..17fcd1119 100644 --- a/scripts/zmcontrol-pelco-p.pl +++ b/scripts/zmcontrol-pelco-p.pl @@ -60,6 +60,8 @@ Usage: zmcontrol-pelco-d.pl exit( -1 ); } +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $arg_string = join( " ", @ARGV ); my $device = "/dev/ttyS0"; diff --git a/scripts/zmcontrol-visca.pl b/scripts/zmcontrol-visca.pl index c22d38ea8..8641b8312 100644 --- a/scripts/zmcontrol-visca.pl +++ b/scripts/zmcontrol-visca.pl @@ -58,6 +58,8 @@ Usage: zmcontrol-visca.pl exit( -1 ); } +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $arg_string = join( " ", @ARGV ); my $device = "/dev/ttyS0"; diff --git a/scripts/zmdc.pl b/scripts/zmdc.pl index 7f00eeb8b..ed49195d3 100644 --- a/scripts/zmdc.pl +++ b/scripts/zmdc.pl @@ -62,6 +62,8 @@ $ENV{PATH} = '/bin:/usr/bin'; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; +zmDbgInit( DBG_ID, DBG_LEVEL ); + my @daemons = ( 'zmc', 'zma', 'zmf', 'zmfilter.pl', 'zmaudit.pl', 'zmtrigger.pl', 'zmx10.pl', 'zmwatch.pl', 'zmupdate.pl', 'zmtrack.pl' ); my $command = shift @ARGV; diff --git a/scripts/zmfilter.pl b/scripts/zmfilter.pl index 6865f54da..c007eb47d 100644 --- a/scripts/zmfilter.pl +++ b/scripts/zmfilter.pl @@ -56,6 +56,8 @@ use Getopt::Long; use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS; use constant LOG_FILE => ZM_PATH_LOGS.'/zmfilter.log'; +zmDbgInit( DBG_ID, DBG_LEVEL ); + if ( ZM_OPT_UPLOAD ) { # Comment these out if you don't have them and don't want to upload diff --git a/scripts/zmpkg.pl b/scripts/zmpkg.pl index d39eb17b4..74a8fc11e 100644 --- a/scripts/zmpkg.pl +++ b/scripts/zmpkg.pl @@ -54,6 +54,8 @@ $ENV{PATH} = '/bin:/usr/bin'; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $command = $ARGV[0]; my $state; diff --git a/scripts/zmtrack.pl b/scripts/zmtrack.pl index f88ea5a9a..ea09c34a0 100644 --- a/scripts/zmtrack.pl +++ b/scripts/zmtrack.pl @@ -76,6 +76,8 @@ if ( !GetOptions( 'monitor=s'=>\$mid ) ) Usage(); } +zmDbgInit( DBG_ID, DBG_LEVEL ); + my ( $detaint_mid ) = $mid =~ /^(\d+)$/; $mid = $detaint_mid; diff --git a/scripts/zmtrigger.pl b/scripts/zmtrigger.pl index 70bcc2f9e..2ae87105e 100644 --- a/scripts/zmtrigger.pl +++ b/scripts/zmtrigger.pl @@ -74,6 +74,8 @@ $ENV{PATH} = '/bin:/usr/bin'; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; +zmDbgInit( DBG_ID, DBG_LEVEL ); + open( LOG, ">>".LOG_FILE ) or die( "Can't open log file: $!" ); open(STDOUT, ">&LOG") || die( "Can't dup stdout: $!" ); select( STDOUT ); $| = 1; diff --git a/scripts/zmupdate.pl b/scripts/zmupdate.pl index fcb54cb54..ee6a7b57b 100644 --- a/scripts/zmupdate.pl +++ b/scripts/zmupdate.pl @@ -60,6 +60,8 @@ $ENV{PATH} = '/bin:/usr/bin'; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $check = 0; my $rename = 0; my $zone_fix = 0; diff --git a/scripts/zmvideo.pl b/scripts/zmvideo.pl index 380766bb0..7b528f260 100644 --- a/scripts/zmvideo.pl +++ b/scripts/zmvideo.pl @@ -55,6 +55,8 @@ $ENV{PATH} = '/bin:/usr/bin'; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $event_id; my $format = 'mpg'; my $rate = ''; diff --git a/scripts/zmwatch.pl b/scripts/zmwatch.pl index 3dc320491..43e28d677 100644 --- a/scripts/zmwatch.pl +++ b/scripts/zmwatch.pl @@ -66,6 +66,8 @@ Usage: zmwatch.pl exit( -1 ); } +zmDbgInit( DBG_ID, DBG_LEVEL ); + open( LOG, '>>'.WATCH_LOG_FILE ) or die( "Can't open log file: $!" ); open( STDOUT, ">&LOG" ) || die( "Can't dup stdout: $!" ); select( STDOUT ); $| = 1; diff --git a/scripts/zmx10.pl b/scripts/zmx10.pl index ea47fef66..001df164f 100644 --- a/scripts/zmx10.pl +++ b/scripts/zmx10.pl @@ -68,6 +68,8 @@ Parameters are :- exit( -1 ); } +zmDbgInit( DBG_ID, DBG_LEVEL ); + my $command; my $unit_code;