FUther debug revisions to correctly tag in syslog etc.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1220 e3e1d417-86f3-4887-817a-d78f3d33393f
pull/27/merge
stan 2005-01-16 16:39:56 +00:00
parent 4bcd7c7d81
commit d2ea7d155f
1 changed files with 19 additions and 7 deletions

View File

@ -37,6 +37,7 @@ static int zm_dbg_line;
static int zm_dbg_code; static int zm_dbg_code;
static char zm_dbg_class[4]; static char zm_dbg_class[4];
char zm_dbg_syslog[64];
char zm_dbg_name[64]; char zm_dbg_name[64];
char zm_dbg_id[64]; char zm_dbg_id[64];
int zm_dbg_level = 0; int zm_dbg_level = 0;
@ -164,21 +165,24 @@ int zmGetDebugEnv()
int zmDebugInitialise( const char *name, const char *id, int level ) int zmDebugInitialise( const char *name, const char *id, int level )
{ {
FILE *tmp_fp; FILE *tmp_fp;
int status; int status;
struct timezone tzp; struct timezone tzp;
gettimeofday( &zm_dbg_start, &tzp ); gettimeofday( &zm_dbg_start, &tzp );
Debug(1,("Initialising Debug")); Debug( 1,( "Initialising Debug" ));
strncpy( zm_dbg_name, name, sizeof(zm_dbg_name) ); strncpy( zm_dbg_name, name, sizeof(zm_dbg_name) );
strncpy( zm_dbg_id, id, sizeof(zm_dbg_id) ); strncpy( zm_dbg_id, id, sizeof(zm_dbg_id) );
zm_dbg_level = level; zm_dbg_level = level;
/* Now set up the syslog stuff */ /* Now set up the syslog stuff */
(void) openlog( zm_dbg_name, LOG_PID|LOG_NDELAY, LOG_LOCAL1 ); if ( zm_dbg_id[0] )
snprintf( zm_dbg_syslog, sizeof(zm_dbg_syslog), "%s_%s", zm_dbg_name, zm_dbg_id );
else
strncpy( zm_dbg_syslog, zm_dbg_name, sizeof(zm_dbg_syslog) );
(void) openlog( zm_dbg_syslog, LOG_PID|LOG_NDELAY, LOG_LOCAL1 );
zm_temp_dbg_string[0] = '\0'; zm_temp_dbg_string[0] = '\0';
zm_dbg_class[0] = '\0'; zm_dbg_class[0] = '\0';
@ -187,10 +191,12 @@ int zmDebugInitialise( const char *name, const char *id, int level )
zm_dbg_log_fd = (FILE *)NULL; zm_dbg_log_fd = (FILE *)NULL;
if( (status = zmGetDebugEnv() ) < 0) if( (status = zmGetDebugEnv() ) < 0)
{ {
Error(("Debug Environment Error, status = %d",status)); Error(( "Debug Environment Error, status = %d", status ));
return(ZM_DBG_ERROR); return(ZM_DBG_ERROR);
} }
strncpy( zm_dbg_name, zm_dbg_syslog, sizeof(zm_dbg_name) );
if ( ( zm_dbg_add_log_id == FALSE && zm_dbg_log[0] ) && ( zm_dbg_log[strlen(zm_dbg_log)-1] == '~' ) ) if ( ( zm_dbg_add_log_id == FALSE && zm_dbg_log[0] ) && ( zm_dbg_log[strlen(zm_dbg_log)-1] == '~' ) )
{ {
zm_dbg_log[strlen(zm_dbg_log)-1] = '\0'; zm_dbg_log[strlen(zm_dbg_log)-1] = '\0';
@ -336,8 +342,14 @@ int zmDbgOutput( const char *fstring, ... )
} }
sprintf(zm_dbg_string,"%s %s[%d].%s-%s/%d [%s]\n", sprintf(zm_dbg_string,"%s %s[%d].%s-%s/%d [%s]\n",
time_string,zm_dbg_name,zm_dbg_pid, time_string,
zm_dbg_class,zm_dbg_file,zm_dbg_line,zm_temp_dbg_string); zm_dbg_name,
zm_dbg_pid,
zm_dbg_class,
zm_dbg_file,
zm_dbg_line,
zm_temp_dbg_string
);
if ( zm_dbg_print ) if ( zm_dbg_print )
{ {
printf("%s", zm_dbg_string); printf("%s", zm_dbg_string);