added log level in log
This commit is contained in:
parent
bd11d8e752
commit
059a2e3c1b
7
main.c
7
main.c
@ -20,6 +20,8 @@
|
|||||||
#define INFO 2
|
#define INFO 2
|
||||||
#define DEBUG 3
|
#define DEBUG 3
|
||||||
|
|
||||||
|
char debug[5][10] = { "[NONE]", "[INFO]", "[WARNING]", "DEBUG" };
|
||||||
|
|
||||||
struct connexion
|
struct connexion
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
@ -73,7 +75,7 @@ int printlog(char str[], int level, int errnum)
|
|||||||
time( &now );
|
time( &now );
|
||||||
if (errnum != 0)
|
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
|
}else
|
||||||
{
|
{
|
||||||
sprintf( tmp, "%s: %s\n", frtime(now), str);
|
sprintf( tmp, "%s: %s\n", frtime(now), str);
|
||||||
@ -82,8 +84,7 @@ int printlog(char str[], int level, int errnum)
|
|||||||
{
|
{
|
||||||
perror(cfg.logfile);
|
perror(cfg.logfile);
|
||||||
retval = EXIT_FAILURE;
|
retval = EXIT_FAILURE;
|
||||||
}
|
}else
|
||||||
if ( retval == EXIT_SUCCESS )
|
|
||||||
{
|
{
|
||||||
fprintf(fh, "%s", tmp);
|
fprintf(fh, "%s", tmp);
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
|
Reference in New Issue
Block a user