X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Flogger.c;h=2b4c7e388ed007a0367969ae6578ba29295452fe;hb=c46bdbde18629f0a0613c776c13a79fea0ec6093;hp=123f02292acefd9a2b9a90a4230756bab321f173;hpb=40ed0c07dd3d4667054b0f5952b89ee39686493b;p=tinc diff --git a/src/logger.c b/src/logger.c index 123f0229..2b4c7e38 100644 --- a/src/logger.c +++ b/src/logger.c @@ -1,6 +1,6 @@ /* logger.c -- logging code - Copyright (C) 2004-2006 Guus Sliepen + Copyright (C) 2004-2013 Guus Sliepen 2004-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -22,6 +22,7 @@ #include "conf.h" #include "meta.h" +#include "names.h" #include "logger.h" #include "connection.h" #include "control_common.h" @@ -30,7 +31,6 @@ debug_t debug_level = DEBUG_NOTHING; static logmode_t logmode = LOGMODE_STDERR; static pid_t logpid; -extern char *logfilename; static FILE *logfile = NULL; #ifdef HAVE_MINGW static HANDLE loghandle = NULL; @@ -41,7 +41,6 @@ bool logcontrol = false; static void real_logger(int level, int priority, const char *message) { char timestr[32] = ""; - time_t now; static bool suppress = false; // Bail out early if there is nothing to do. @@ -58,8 +57,10 @@ static void real_logger(int level, int priority, const char *message) { fflush(stderr); break; case LOGMODE_FILE: - now = time(NULL); - strftime(timestr, sizeof timestr, "%Y-%m-%d %H:%M:%S", localtime(&now)); + if(!now.tv_sec) + gettimeofday(&now, NULL); + time_t now_sec = now.tv_sec; + strftime(timestr, sizeof timestr, "%Y-%m-%d %H:%M:%S", localtime(&now_sec)); fprintf(logfile, "%s %s[%ld]: %s\n", timestr, logident, (long)logpid, message); fflush(logfile); break;