mirror of
https://github.com/LibreOffice/online.git
synced 2025-08-20 23:24:34 +00:00
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
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Poco/ConsoleChannel.h>
|
||||
#include <Poco/DateTimeFormatter.h>
|
||||
#include <Poco/FileChannel.h>
|
||||
#include <Poco/FormattingChannel.h>
|
||||
#include <Poco/PatternFormatter.h>
|
||||
@ -36,8 +37,6 @@ namespace Log
|
||||
{
|
||||
using namespace Poco;
|
||||
|
||||
static const Poco::Int64 epochStart = Poco::Timestamp().epochMicroseconds();
|
||||
|
||||
/// Helper to avoid destruction ordering issues.
|
||||
struct StaticNames
|
||||
{
|
||||
@ -82,15 +81,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)
|
||||
@ -101,9 +92,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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user