Modify function from localtime to localtime_r
This commit is contained in:
parent
f9ea34994b
commit
7dc98a0d1b
@ -52,7 +52,7 @@ static const char *level_colors[] = {
|
||||
|
||||
static void stdout_callback(log_Event *ev) {
|
||||
char buf[16];
|
||||
buf[strftime(buf, sizeof(buf), "%H:%M:%S", ev->time)] = '\0';
|
||||
buf[strftime(buf, sizeof(buf), "%H:%M:%S", &ev->time)] = '\0';
|
||||
#ifdef LOG_USE_COLOR
|
||||
fprintf(
|
||||
ev->udata, "%s %s%-5s\x1b[0m \x1b[90m%s:%d:\x1b[0m ",
|
||||
@ -71,7 +71,7 @@ static void stdout_callback(log_Event *ev) {
|
||||
|
||||
static void file_callback(log_Event *ev) {
|
||||
char buf[64];
|
||||
buf[strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ev->time)] = '\0';
|
||||
buf[strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &ev->time)] = '\0';
|
||||
fprintf(
|
||||
ev->udata, "%s %-5s %s:%d: ",
|
||||
buf, level_strings[ev->level], ev->file, ev->line);
|
||||
@ -129,9 +129,9 @@ int log_add_fp(FILE *fp, int level) {
|
||||
|
||||
|
||||
static void init_event(log_Event *ev, void *udata) {
|
||||
if (!ev->time) {
|
||||
if (!(&ev->time)) {
|
||||
time_t t = time(NULL);
|
||||
ev->time = localtime(&t);
|
||||
localtime_r(&t, &ev->time);
|
||||
}
|
||||
ev->udata = udata;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user