X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/daa70b179888121b92554103817443ad0ef32cd8..6e05f333a29e379264a6a8949fc2f44d555d632e:/src/slowlog.c?ds=sidebyside diff --git a/src/slowlog.c b/src/slowlog.c index ecaf6508..cfd66dc6 100644 --- a/src/slowlog.c +++ b/src/slowlog.c @@ -26,6 +26,7 @@ slowlogEntry *slowlogCreateEntry(robj **argv, int argc, long long duration) { } se->time = time(NULL); se->duration = duration; + se->id = server.slowlog_entry_id++; return se; } @@ -47,6 +48,7 @@ void slowlogFreeEntry(void *septr) { * at server startup. */ void slowlogInit(void) { server.slowlog = listCreate(); + server.slowlog_entry_id = 0; listSetFreeMethod(server.slowlog,slowlogFreeEntry); } @@ -54,7 +56,8 @@ void slowlogInit(void) { * This function will make sure to trim the slow log accordingly to the * configured max length. */ void slowlogPushEntryIfNeeded(robj **argv, int argc, long long duration) { - if (duration > server.slowlog_log_slower_than) + if (server.slowlog_log_slower_than < 0) return; /* Slowlog disabled */ + if (duration >= server.slowlog_log_slower_than) listAddNodeHead(server.slowlog,slowlogCreateEntry(argv,argc,duration)); /* Remove old entries if needed. */ @@ -95,7 +98,8 @@ void slowlogCommand(redisClient *c) { int j; se = ln->value; - addReplyMultiBulkLen(c,3); + addReplyMultiBulkLen(c,4); + addReplyLongLong(c,se->id); addReplyLongLong(c,se->time); addReplyLongLong(c,se->duration); addReplyMultiBulkLen(c,se->argc);