Skip to content

Commit

Permalink
Update slog.c
Browse files Browse the repository at this point in the history
  • Loading branch information
kala13x committed May 3, 2015
1 parent 7d5aeb9 commit ed8d864
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion slog.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,38 @@ int parse_config(char *cfg_name)
}


/*---------------------------------------------
| Return string in slog format
---------------------------------------------*/
char* ret_slog(char *msg, ...)
{
/* Used variables */
char output[MAXMSG];
char string[MAXMSG];
char* mout;
SystemDate mdate;

/* initialise system date */
init_date(&mdate);

/* Read args */
va_list args;
va_start(args, msg);
vsprintf(string, msg, args);
va_end(args);

/* Generate output string with date */
sprintf(output, "%02d.%02d.%02d-%02d:%02d:%02d - %s",
mdate.year, mdate.mon, mdate.day, mdate.hour, mdate.min, mdate.sec, string);

/* Allocate output */
mout = strdup(output);

/* Return output */
return mout;
}


/*---------------------------------------------
| Log exiting process
---------------------------------------------*/
Expand Down Expand Up @@ -179,4 +211,4 @@ void init_slog(char* fname, int max)
slog(0, "[WARNING] - loglevel and/or logtofile flag is not set from config.");
return;
}
}
}

0 comments on commit ed8d864

Please sign in to comment.