Browse Source

Merge branch 'master' of bitbucket.org:ckolivas/ckpool

master
Con Kolivas 10 years ago
parent
commit
1e22c8a99f
  1. 12
      src/ckdb.c
  2. 14
      src/ckpool.c

12
src/ckdb.c

@ -561,7 +561,8 @@ void logmsg(int loglevel, const char *fmt, ...)
int logfd = 0; int logfd = 0;
char *buf = NULL; char *buf = NULL;
struct tm tm; struct tm tm;
time_t now_t; tv_t now_tv;
int ms;
va_list ap; va_list ap;
char stamp[128]; char stamp[128];
char *extra = EMPTY; char *extra = EMPTY;
@ -572,8 +573,9 @@ void logmsg(int loglevel, const char *fmt, ...)
if (loglevel > global_ckp->loglevel) if (loglevel > global_ckp->loglevel)
return; return;
now_t = time(NULL); tv_time(&now_tv);
localtime_r(&now_t, &tm); ms = (int)(now_tv.tv_usec / 1000);
localtime_r(&(now_tv.tv_sec), &tm);
minoff = tm.tm_gmtoff / 60; minoff = tm.tm_gmtoff / 60;
if (minoff < 0) { if (minoff < 0) {
tzch = '-'; tzch = '-';
@ -591,13 +593,13 @@ void logmsg(int loglevel, const char *fmt, ...)
tzch, hroff); tzch, hroff);
} }
snprintf(stamp, sizeof(stamp), snprintf(stamp, sizeof(stamp),
"[%d-%02d-%02d %02d:%02d:%02d%s]", "[%d-%02d-%02d %02d:%02d:%02d.%03d%s]",
tm.tm_year + 1900, tm.tm_year + 1900,
tm.tm_mon + 1, tm.tm_mon + 1,
tm.tm_mday, tm.tm_mday,
tm.tm_hour, tm.tm_hour,
tm.tm_min, tm.tm_min,
tm.tm_sec, tm.tm_sec, ms,
tzinfo); tzinfo);
if (!fmt) { if (!fmt) {

14
src/ckpool.c

@ -64,7 +64,8 @@ void logmsg(int loglevel, const char *fmt, ...) {
int logfd = global_ckp->logfd; int logfd = global_ckp->logfd;
char *buf = NULL; char *buf = NULL;
struct tm tm; struct tm tm;
time_t now_t; tv_t now_tv;
int ms;
va_list ap; va_list ap;
char stamp[128]; char stamp[128];
@ -72,16 +73,17 @@ void logmsg(int loglevel, const char *fmt, ...) {
VASPRINTF(&buf, fmt, ap); VASPRINTF(&buf, fmt, ap);
va_end(ap); va_end(ap);
now_t = time(NULL); tv_time(&now_tv);
localtime_r(&now_t, &tm); ms = (int)(now_tv.tv_usec / 1000);
sprintf(stamp, "[%d-%02d-%02d %02d:%02d:%02d]", localtime_r(&(now_tv.tv_sec), &tm);
sprintf(stamp, "[%d-%02d-%02d %02d:%02d:%02d.%03d]",
tm.tm_year + 1900, tm.tm_year + 1900,
tm.tm_mon + 1, tm.tm_mon + 1,
tm.tm_mday, tm.tm_mday,
tm.tm_hour, tm.tm_hour,
tm.tm_min, tm.tm_min,
tm.tm_sec); tm.tm_sec, ms);
if (loglevel <= LOG_WARNING) {\ if (loglevel <= LOG_WARNING) {
if (loglevel <= LOG_ERR && errno != 0) if (loglevel <= LOG_ERR && errno != 0)
fprintf(stderr, "%s %s with errno %d: %s\n", stamp, buf, errno, strerror(errno)); fprintf(stderr, "%s %s with errno %d: %s\n", stamp, buf, errno, strerror(errno));
else else

Loading…
Cancel
Save