diff --git a/main.c b/main.c index 79abf45..f033348 100644 --- a/main.c +++ b/main.c @@ -20,6 +20,8 @@ #define INFO 2 #define DEBUG 3 +char debug[5][10] = { "[NONE]", "[INFO]", "[WARNING]", "DEBUG" }; + struct connexion { int pid; @@ -73,7 +75,7 @@ int printlog(char str[], int level, int errnum) time( &now ); if (errnum != 0) { - sprintf( tmp, "%s: %s %s\n", frtime(now), str, strerror(errnum)); + sprintf( tmp, "%s %s: %s %s\n", debug[level], frtime(now), str, strerror(errnum)); }else { sprintf( tmp, "%s: %s\n", frtime(now), str); @@ -82,8 +84,7 @@ int printlog(char str[], int level, int errnum) { perror(cfg.logfile); retval = EXIT_FAILURE; - } - if ( retval == EXIT_SUCCESS ) + }else { fprintf(fh, "%s", tmp); fclose(fh);