[Libreoffice-commits] online.git: Branch 'libreoffice-5-3' - common/Log.cpp
Jan Holesovsky
kendy at collabora.com
Thu Mar 23 10:13:25 UTC 2017
common/Log.cpp | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
New commits:
commit a4bd4e42beee511ca1747c2e4b2a35f13ab2fe22
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Jan 13 16:09:47 2017 +0100
Log the time in wall-clock time, instead of since the process start.
Otherwise we are getting completely confused times - various processes start
at various times, so for one process the epoch start can be eg. 20 minutes
later than for the other.
Change-Id: I6d87e98682a5fcd0348a584cf66f7ffa5813ca66
Reviewed-on: https://gerrit.libreoffice.org/35569
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/common/Log.cpp b/common/Log.cpp
index c263975d..df2286d8 100644
--- a/common/Log.cpp
+++ b/common/Log.cpp
@@ -19,6 +19,7 @@
#include <unistd.h>
#include <Poco/ConsoleChannel.h>
+#include <Poco/DateTimeFormatter.h>
#include <Poco/FileChannel.h>
#include <Poco/FormattingChannel.h>
#include <Poco/PatternFormatter.h>
@@ -35,8 +36,6 @@ namespace Log
{
using namespace Poco;
- static const Poco::Int64 epochStart = Poco::Timestamp().epochMicroseconds();
-
/// Helper to avoid destruction ordering issues.
struct StaticNames
{
@@ -81,15 +80,7 @@ namespace Log
// FIXME: If running under systemd it is redundant to output timestamps, as those will be
// attached to messages that the systemd journalling mechanism picks up anyway, won't they?
- Poco::Int64 usec = Poco::Timestamp().epochMicroseconds() - epochStart;
-
- const Poco::Int64 one_s = 1000000;
- const Poco::Int64 hours = usec / (one_s*60*60);
- usec %= (one_s * 60 * 60);
- const Poco::Int64 minutes = usec / (one_s*60);
- usec %= (one_s * 60);
- const Poco::Int64 seconds = usec / (one_s);
- usec %= (one_s);
+ std::string time = DateTimeFormatter::format(Poco::Timestamp(), "%H:%M:%s");
char procName[32]; // we really need only 16
if (prctl(PR_GET_NAME, reinterpret_cast<unsigned long>(procName), 0, 0, 0) != 0)
@@ -100,9 +91,9 @@ namespace Log
const char* appName = (Source.inited ? Source.id.c_str() : "<shutdown>");
assert(strlen(appName) + 32 + 28 < 1024 - 1);
- snprintf(buffer, 4095, "%s-%.04lu %d:%.2d:%.2d.%.6d [ %s ] %s ", appName,
+ snprintf(buffer, 4095, "%s-%.04lu %s [ %s ] %s ", appName,
syscall(SYS_gettid),
- (int)hours, (int)minutes, (int)seconds, (int)usec,
+ time.c_str(),
procName, level);
}
More information about the Libreoffice-commits
mailing list