From 2e324d817737c153613a422c4586deb11ea1a19b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 6 Sep 2017 23:29:29 +0200 Subject: [PATCH] log: set epoch already in log_init() --- lib/log.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/log.c b/lib/log.c index 02b37db54..b08fa2f11 100644 --- a/lib/log.c +++ b/lib/log.c @@ -47,11 +47,11 @@ void register_default_log() { int ret; static struct log default_log; - + ret = log_init(&default_log, V, LOG_ALL); if (ret) error("Failed to initalize log"); - + ret = log_start(&default_log); if (ret) error("Failed to start log"); @@ -134,6 +134,9 @@ int log_init(struct log *l, int level, long facilitites) l->window.ws_col = LOG_WIDTH; l->window.ws_row = LOG_HEIGHT; + l->epoch = time_now(); + l->prefix = getenv("VILLAS_LOG_PREFIX"); + /* Register signal handler which is called whenever the * terminal size changes. */ if (l->file == stderr) { @@ -159,9 +162,6 @@ int log_init(struct log *l, int level, long facilitites) int log_start(struct log *l) { - l->epoch = time_now(); - l->prefix = getenv("VILLAS_LOG_PREFIX"); - l->file = l->path ? fopen(l->path, "a+") : stderr; if (!l->file) { l->file = stderr; @@ -261,7 +261,7 @@ void log_vprint(struct log *l, const char *lvl, const char *fmt, va_list ap) { struct timespec ts = time_now(); char *buf = alloc(512); - + /* Optional prefix */ if (l->prefix) strcatf(&buf, "%s", l->prefix);