summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2010-07-22 23:29:07 +0200
committerantirez <antirez@gmail.com>2010-07-22 23:29:07 +0200
commitfe2173ae530b27b8e039be4aa00817f7672c5b10 (patch)
treef04b5586f272853a32a9c4136cab028b11ca010e
parentde4aebe9fd4758a6ec95ce64cd3661b9950db9b7 (diff)
downloadredis-fe2173ae530b27b8e039be4aa00817f7672c5b10.tar.gz
don't open/close log file if log level is not matchedv2.0.0-rc3
-rw-r--r--redis.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/redis.c b/redis.c
index ff0c46533..8e8831aea 100644
--- a/redis.c
+++ b/redis.c
@@ -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);