diff options
author | Mateusz Kusiak <mateusz.kusiak@intel.com> | 2024-11-20 18:20:32 +0100 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-11-22 09:00:32 +0100 |
commit | 655012434b7c059811a5f26001e47dd418f20a36 (patch) | |
tree | a5c604c67227b5a65d03b683aff40e04e864eeb1 /mdadm.h | |
parent | CI: assign ret to numeric value (diff) | |
download | mdadm-655012434b7c059811a5f26001e47dd418f20a36.tar.xz mdadm-655012434b7c059811a5f26001e47dd418f20a36.zip |
debug: add timestamps for debug messages
Timestamps on debug messages help establish what takes long to process.
Debug messages are print only if DDEBUG flag is passed.
Add timestamps for debug messages. Remove dead code from dprintf dummies
for non-debug builds. Remove timestamps from current debug messages.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Diffstat (limited to 'mdadm.h')
-rw-r--r-- | mdadm.h | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -1899,15 +1899,23 @@ static inline sighandler_t signal_s(int sig, sighandler_t handler) } #ifdef DEBUG +#include <time.h> + #define dprintf(fmt, arg...) \ - fprintf(stderr, "%s: %s: "fmt, Name, __func__, ##arg) + do { \ + struct timespec ts; \ + clock_gettime(CLOCK_MONOTONIC, &ts); \ + double timestamp = ts.tv_sec + ts.tv_nsec / 1e9; \ + fprintf(stderr, "[%10.5f] %s: %s: " fmt, timestamp, Name, __func__, ##arg); \ + } while (0) + #define dprintf_cont(fmt, arg...) \ fprintf(stderr, fmt, ##arg) #else #define dprintf(fmt, arg...) \ - ({ if (0) fprintf(stderr, "%s: %s: " fmt, Name, __func__, ##arg); 0; }) + do { } while (0) #define dprintf_cont(fmt, arg...) \ - ({ if (0) fprintf(stderr, fmt, ##arg); 0; }) + do { } while (0) #endif static inline int xasprintf(char **strp, const char *fmt, ...) { |