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
23072961
Commit
23072961
authored
Jul 22, 2010
by
antirez
Browse files
don't open/close log file if log level is not matched
parent
c8a10631
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis.c
View file @
23072961
...
@@ -186,23 +186,22 @@ struct redisCommand readonlyCommandTable[] = {
...
@@ -186,23 +186,22 @@ struct redisCommand readonlyCommandTable[] = {
void
redisLog
(
int
level
,
const
char
*
fmt
,
...)
{
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
)
{
char
*
c
=
".-*#"
;
char
buf
[
64
];
time_t
now
;
now
=
time
(
NULL
);
now
=
time
(
NULL
);
strftime
(
buf
,
64
,
"%d %b %H:%M:%S"
,
localtime
(
&
now
));
strftime
(
buf
,
64
,
"%d %b %H:%M:%S"
,
localtime
(
&
now
));
fprintf
(
fp
,
"[%d] %s %c "
,(
int
)
getpid
(),
buf
,
c
[
level
]);
fprintf
(
fp
,
"[%d] %s %c "
,(
int
)
getpid
(),
buf
,
c
[
level
]);
vfprintf
(
fp
,
fmt
,
ap
);
vfprintf
(
fp
,
fmt
,
ap
);
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
"
\n
"
);
fflush
(
fp
);
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