diff options
author | antirez <antirez@gmail.com> | 2010-07-22 23:29:07 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2010-07-22 23:29:07 +0200 |
commit | fe2173ae530b27b8e039be4aa00817f7672c5b10 (patch) | |
tree | f04b5586f272853a32a9c4136cab028b11ca010e | |
parent | de4aebe9fd4758a6ec95ce64cd3661b9950db9b7 (diff) | |
download | redis-fe2173ae530b27b8e039be4aa00817f7672c5b10.tar.gz |
don't open/close log file if log level is not matchedv2.0.0-rc3
-rw-r--r-- | redis.c | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -1058,23 +1058,22 @@ static int ll2string(char *s, size_t len, long long value) { static void redisLog(int level, const char *fmt, ...) { va_list ap; FILE *fp; + char *c = ".-*#"; + char buf[64]; + time_t now; + + if (level < server.verbosity) return; fp = (server.logfile == NULL) ? stdout : fopen(server.logfile,"a"); if (!fp) return; va_start(ap, fmt); - if (level >= server.verbosity) { - char *c = ".-*#"; - char buf[64]; - time_t now; - - now = time(NULL); - strftime(buf,64,"%d %b %H:%M:%S",localtime(&now)); - fprintf(fp,"[%d] %s %c ",(int)getpid(),buf,c[level]); - vfprintf(fp, fmt, ap); - fprintf(fp,"\n"); - fflush(fp); - } + now = time(NULL); + strftime(buf,64,"%d %b %H:%M:%S",localtime(&now)); + fprintf(fp,"[%d] %s %c ",(int)getpid(),buf,c[level]); + vfprintf(fp, fmt, ap); + fprintf(fp,"\n"); + fflush(fp); va_end(ap); if (server.logfile) fclose(fp); |