projects
/
redis.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3c413d5
)
Print milliseconds of the current second in log lines timestamps. Sometimes precise...
author
antirez
<antirez@gmail.com>
Wed, 4 Apr 2012 13:11:17 +0000
(15:11 +0200)
committer
antirez
<antirez@gmail.com>
Wed, 4 Apr 2012 16:32:59 +0000
(18:32 +0200)
src/redis.c
patch
|
blob
|
blame
|
history
diff --git
a/src/redis.c
b/src/redis.c
index 0bff9339143385ab23b5313d9427e3b017dcf4ff..a7610fa4d7fd021ff8c75b5132e5d79cf867fdff 100644
(file)
--- a/
src/redis.c
+++ b/
src/redis.c
@@
-251,7
+251,6
@@
struct redisCommand redisCommandTable[] = {
void redisLogRaw(int level, const char *msg) {
const int syslogLevelMap[] = { LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_WARNING };
const char *c = ".-*#";
void redisLogRaw(int level, const char *msg) {
const int syslogLevelMap[] = { LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_WARNING };
const char *c = ".-*#";
- time_t now = time(NULL);
FILE *fp;
char buf[64];
int rawmode = (level & REDIS_LOG_RAW);
FILE *fp;
char buf[64];
int rawmode = (level & REDIS_LOG_RAW);
@@
-265,7
+264,12
@@
void redisLogRaw(int level, const char *msg) {
if (rawmode) {
fprintf(fp,"%s",msg);
} else {
if (rawmode) {
fprintf(fp,"%s",msg);
} else {
- strftime(buf,sizeof(buf),"%d %b %H:%M:%S",localtime(&now));
+ int off;
+ struct timeval tv;
+
+ gettimeofday(&tv,NULL);
+ off = strftime(buf,sizeof(buf),"%d %b %H:%M:%S.",localtime(&tv.tv_sec));
+ snprintf(buf+off,sizeof(buf)-off,"%03d",(int)tv.tv_usec/1000);
fprintf(fp,"[%d] %s %c %s\n",(int)getpid(),buf,c[level],msg);
}
fflush(fp);
fprintf(fp,"[%d] %s %c %s\n",(int)getpid(),buf,c[level],msg);
}
fflush(fp);