From 446788f2ed0deb2689400f4864123c4477451cb3 Mon Sep 17 00:00:00 2001 From: Marko Date: Tue, 7 May 2019 13:24:18 +0300 Subject: [PATCH] MXS-1799 Add timestamps to retain_last_statements messages --- server/core/internal/session.hh | 5 +++++ server/core/session.cc | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/server/core/internal/session.hh b/server/core/internal/session.hh index 4985cfa84..527fcdfc4 100644 --- a/server/core/internal/session.hh +++ b/server/core/internal/session.hh @@ -136,6 +136,11 @@ public: return m_sQuery; } + timespec time_completed() const + { + return m_completed; + } + void book_server_response(SERVER* pServer, bool final_response); void book_as_complete(); void reset_server_bookkeeping(); diff --git a/server/core/session.cc b/server/core/session.cc index 07dfb2e2f..e618c8ee0 100644 --- a/server/core/session.cc +++ b/server/core/session.cc @@ -1209,6 +1209,10 @@ void Session::dump_statements() const { const QueryInfo& info = *i; GWBUF* pBuffer = info.query().get(); + timespec ts = info.time_completed(); + struct tm *tm = localtime(&ts.tv_sec); + char timestamp[20]; + strftime(timestamp, 20, "%Y-%m-%d %H:%M:%S", tm); const char* pCmd; char* pStmt; @@ -1219,14 +1223,14 @@ void Session::dump_statements() const { if (id != 0) { - MXS_NOTICE("Stmt %d: %.*s", n, len, pStmt); + MXS_NOTICE("Stmt %d(%s): %.*s", n, timestamp, len, pStmt); } else { // We are in a context where we do not have a current session, so we need to // log the session id ourselves. - MXS_NOTICE("(%" PRIu64 ") Stmt %d: %.*s", ses_id, n, len, pStmt); + MXS_NOTICE("(%" PRIu64 ") Stmt %d(%s): %.*s", ses_id, n, timestamp, len, pStmt); } if (deallocate)