From 059a2e3c1b8c04cef52099e35ef4a74c504101f0 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Mon, 8 Jun 2020 14:53:48 +0200 Subject: [PATCH] added log level in log --- main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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);