1
0

added log level in log

This commit is contained in:
Daniel Tartavel 2020-06-08 14:53:48 +02:00
parent bd11d8e752
commit 059a2e3c1b

7
main.c
View File

@ -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);