File 0001-Log-all-use-high-resolution-timestamps-in-detail-log.patch of Package pacemaker.26124
From 5a33121e34998649d249150e4a0babf055cfd4f1 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Wed, 13 Jan 2021 09:56:49 -0600
Subject: [PATCH] Log: all: use high-resolution timestamps in detail log when
available
---
lib/common/logging.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
Index: pacemaker-2.0.1+20190417.13d370ca9/lib/common/logging.c
===================================================================
--- pacemaker-2.0.1+20190417.13d370ca9.orig/lib/common/logging.c
+++ pacemaker-2.0.1+20190417.13d370ca9/lib/common/logging.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2019 the Pacemaker project contributors
+ * Copyright 2004-2021 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -33,6 +33,15 @@
#include <crm/crm.h>
#include <crm/common/mainloop.h>
+// Use high-resolution (millisecond) timestamps if libqb supports them
+#ifdef QB_FEATURE_LOG_HIRES_TIMESTAMPS
+#define TIMESTAMP_FORMAT_SPEC "%%T"
+typedef struct timespec *log_time_t;
+#else
+#define TIMESTAMP_FORMAT_SPEC "%%t"
+typedef time_t log_time_t;
+#endif
+
unsigned int crm_log_priority = LOG_NOTICE;
unsigned int crm_log_level = LOG_INFO;
static gboolean crm_tracing_enabled(void);
@@ -205,7 +214,7 @@ set_format_string(int method, const char
// If logging to file, prefix with timestamp, node name, daemon ID
offset += snprintf(fmt + offset, FMT_MAX - offset,
- "%%t %s %-20s[%lu] ",
+ TIMESTAMP_FORMAT_SPEC " %s %-20s[%lu] ",
nodename, daemon, (unsigned long) getpid());
}
@@ -358,12 +367,6 @@ crm_add_logfile(const char *filename)
static int blackbox_trigger = 0;
static volatile char *blackbox_file_prefix = NULL;
-#ifdef QB_FEATURE_LOG_HIRES_TIMESTAMPS
-typedef struct timespec *log_time_t;
-#else
-typedef time_t log_time_t;
-#endif
-
static void
blackbox_logger(int32_t t, struct qb_log_callsite *cs, log_time_t timestamp,
const char *msg)