/*
logger.c -- logging code
- Copyright (C) 2004-2006 Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 2004-2012 Guus Sliepen <guus@tinc-vpn.org>
2004-2005 Ivo Timmermans
This program is free software; you can redistribute it and/or modify
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.
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;