From f52f2c2828047c2f30d30fc1fe2b54d8db146d49 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期四, 25 二月 2021 15:56:35 +0800 Subject: [PATCH] update --- include/usgcommon/logger.h | 29 ++--------------------------- 1 files changed, 2 insertions(+), 27 deletions(-) diff --git a/include/usgcommon/logger.h b/include/usgcommon/logger.h index cf0d2ba..ccf17cd 100644 --- a/include/usgcommon/logger.h +++ b/include/usgcommon/logger.h @@ -16,32 +16,7 @@ LoggerConfig config; FILE *logFile; - void dolog(const char *fmt, va_list ap, int level, int err = 0) { - char buf[MAXLINE]; - - struct timeval tv; - struct tm *info; - gettimeofday(&tv, NULL); - info = localtime(&tv.tv_sec); - strftime(buf, MAXBUF - 1, "%Y-%d-%m %H:%M:%S", info); - snprintf(buf + strlen(buf), MAXBUF - strlen(buf) - 1, ",%ld [%s] ", tv.tv_usec, strlevel(level)); - vsnprintf(buf + strlen(buf), MAXBUF - strlen(buf) - 1, fmt, ap); - - if (err != 0) { - snprintf(buf + strlen(buf), MAXBUF - strlen(buf) - 1, ": %s", strerror(err)); - } - strcat(buf, "\n"); - fflush(stdout); /* in case stdout and stderr are the same */ - - if(logFile != NULL) { - fputs(buf, logFile); - } - if(config.console) { - fputs(buf, stdout); - } - - fflush(NULL); /* flushes all stdio output streams */ - } + void dolog(const char *fmt, va_list ap, int level, int err = 0); void init(); @@ -66,7 +41,7 @@ void error(const char *fmt, ...); void error(int err, const char *fmt, ...); void fatal(const char *fmt, ...); - + void fatal(int err, const char *fmt, ...) ; static const char * strlevel(int level); }; -- Gitblit v1.8.0