Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
fe2173ae
Commit
fe2173ae
authored
Jul 22, 2010
by
antirez
Browse files
don't open/close log file if log level is not matched
parent
de4aebe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
fe2173ae
...
@@ -1058,23 +1058,22 @@ static int ll2string(char *s, size_t len, long long value) {
...
@@ -1058,23 +1058,22 @@ static int ll2string(char *s, size_t len, long long value) {
static void redisLog(int level, const char *fmt, ...) {
static void redisLog(int level, const char *fmt, ...) {
va_list ap;
va_list ap;
FILE *fp;
FILE *fp;
char *c = ".-*#";
char buf[64];
time_t now;
if (level < server.verbosity) return;
fp = (server.logfile == NULL) ? stdout : fopen(server.logfile,"a");
fp = (server.logfile == NULL) ? stdout : fopen(server.logfile,"a");
if (!fp) return;
if (!fp) return;
va_start(ap, fmt);
va_start(ap, fmt);
if (level >= server.verbosity) {
now = time(NULL);
char *c = ".-*#";
strftime(buf,64,"%d %b %H:%M:%S",localtime(&now));
char buf[64];
fprintf(fp,"[%d] %s %c ",(int)getpid(),buf,c[level]);
time_t now;
vfprintf(fp, fmt, ap);
fprintf(fp,"\n");
now = time(NULL);
fflush(fp);
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);
va_end(ap);
if (server.logfile) fclose(fp);
if (server.logfile) fclose(fp);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment