From ca581148cd0bcda24fba72e8cf7b18e88ebb56af Mon Sep 17 00:00:00 2001 From: Charles Hardin <53844049+chardin-cpi@users.noreply.github.com> Date: Fri, 24 Feb 2023 15:33:37 -0800 Subject: [PATCH] Add optional TID definition to the systemd sink send (#2619) From the systemd.journal-fields the TID is a user defined field passed directly from the clients and stored in the journal. Adding the arguement in the journal send to support that storage option in the journal. --- include/spdlog/sinks/systemd_sink.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/spdlog/sinks/systemd_sink.h b/include/spdlog/sinks/systemd_sink.h index e1e97bffe0..f889f7d55e 100644 --- a/include/spdlog/sinks/systemd_sink.h +++ b/include/spdlog/sinks/systemd_sink.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include @@ -75,11 +76,17 @@ class systemd_sink : public base_sink { // Note: function call inside '()' to avoid macro expansion err = (sd_journal_send)("MESSAGE=%.*s", static_cast(length), payload.data(), "PRIORITY=%d", syslog_level(msg.level), +#ifndef SPDLOG_NO_THREAD_ID + "TID=%zu", os::thread_id(), +#endif "SYSLOG_IDENTIFIER=%.*s", static_cast(syslog_identifier.size()), syslog_identifier.data(), nullptr); } else { err = (sd_journal_send)("MESSAGE=%.*s", static_cast(length), payload.data(), "PRIORITY=%d", syslog_level(msg.level), +#ifndef SPDLOG_NO_THREAD_ID + "TID=%zu", os::thread_id(), +#endif "SYSLOG_IDENTIFIER=%.*s", static_cast(syslog_identifier.size()), syslog_identifier.data(), "CODE_FILE=%s", msg.source.filename, "CODE_LINE=%d", msg.source.line, "CODE_FUNC=%s", msg.source.funcname, nullptr); }