diff --git a/main.c b/main.c index 393133a..527ce3d 100644 --- a/main.c +++ b/main.c @@ -20,7 +20,8 @@ #define INFO 2 #define DEBUG 3 -char debug[5][10] = { "[NONE]", "[INFO]", "[WARNING]", "DEBUG" }; +char debug[5][10] = { "[NONE]", "[INFO]", "[WARNING]", "[DEBUG]" }; +char fn[30] = ""; struct connexion { @@ -58,6 +59,7 @@ char * frtime(const time_t timet) struct tm *date_tm; static char result[40]; + strcpy( fn, "frtime"); date_tm = localtime(&timet); strftime(result, 40, "%c", date_tm); return result; @@ -69,6 +71,7 @@ int printlog(char str[], int level, int errnum) time_t now = 0; char tmp[128]; int retval = EXIT_SUCCESS; + static char fn_tmp[30]; if ( level <= loglevel ) { @@ -86,6 +89,11 @@ int printlog(char str[], int level, int errnum) retval = EXIT_FAILURE; }else { + if( strcmp(fn, fn_tmp) != 0 ) + { + fprintf(fh, "%s", fn); + strcpy(fn_tmp, fn); + } fprintf(fh, "%s", tmp); fclose(fh); } @@ -99,6 +107,7 @@ int explode( char * str, char * separator, size_t m, size_t n, char exploded[m][ char * pch; int x=0 ; + strcpy( fn, "explode"); pch = strtok( str, separator ); while( pch != NULL ) { @@ -224,6 +233,7 @@ int isinarray( int pid, int array[], int n ) int x; char strlog[128]; + strcpy( fn, "isinarray"); for(x=1;x<=n;x++) { if( pid == array[x]) @@ -239,6 +249,7 @@ int isinarray( int pid, int array[], int n ) // initialize config file watching int init_config_watch( char config_file[], struct notify_config * ncc ) { + strcpy( fn, "init_config_watch" ); ncc->fd = inotify_init(); if ( ncc->fd < 0 ) { @@ -265,6 +276,7 @@ int notify_config_change(struct notify_config * ncc, char config_file[]) struct timeval tv = {1,0}; int retval; + strcpy( fn, "notify_config_change"); FD_ZERO(&rfds); FD_SET(ncc->fd, &rfds); retval = select(ncc->fd+1, &rfds, NULL, NULL, &tv); @@ -310,6 +322,7 @@ void getutmp( struct connexion * conn, time_t * time ) char str[6]; char strlog[128]; + strcpy( fn, "getutpm"); conn->host_ip[0]='\0'; conn->host_ipv6[0]='\0'; setutent(); @@ -399,6 +412,7 @@ int getpids(int pid, int exploded[]) char separator[] = " "; int x = 0; + strcpy( fn, "getpids"); sprintf( path, "/proc/%d/task/%d/children", pid, pid); sprintf(strlog, "process path: %s", path); printlog(strlog, DEBUG,0); @@ -439,6 +453,7 @@ int getprocinfo( struct connexion * conn ) //char tab[128]; time_t timet=0; + strcpy( fn, "getprocinfo"); //get connexion time getutmp( conn, &timet ); if ( timet == 0) @@ -524,6 +539,7 @@ int main() struct notify_config ncc; //char * ptr; + strcpy( fn, "main"); // Loading configuration readconfig( &cfg );