mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
Print milliseconds of the current second in log lines timestamps. Sometimes precise timing is very important for debugging.
This commit is contained in:
parent
1ad4d50805
commit
9a322ab730
@ -253,7 +253,6 @@ struct redisCommand redisCommandTable[] = {
|
|||||||
void redisLogRaw(int level, const char *msg) {
|
void redisLogRaw(int level, const char *msg) {
|
||||||
const int syslogLevelMap[] = { LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_WARNING };
|
const int syslogLevelMap[] = { LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_WARNING };
|
||||||
const char *c = ".-*#";
|
const char *c = ".-*#";
|
||||||
time_t now = time(NULL);
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
int rawmode = (level & REDIS_LOG_RAW);
|
int rawmode = (level & REDIS_LOG_RAW);
|
||||||
@ -267,7 +266,12 @@ void redisLogRaw(int level, const char *msg) {
|
|||||||
if (rawmode) {
|
if (rawmode) {
|
||||||
fprintf(fp,"%s",msg);
|
fprintf(fp,"%s",msg);
|
||||||
} else {
|
} 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);
|
fprintf(fp,"[%d] %s %c %s\n",(int)getpid(),buf,c[level],msg);
|
||||||
}
|
}
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user