Commit a44560dd authored by Jan Kundrát's avatar Jan Kundrát

journald: fix source file location

This is what my manpage says, and what the original blog post [1] says
as well.

Also, `sd_journal_send` can add the location of its own invocation to
the log. That's typically not what we want, so we have to suppress that
feature and instead put whatever is inside the spdlog message into the
journal.

[1] http://0pointer.de/blog/projects/journal-submit.html
parent 2b8afb38
......@@ -8,6 +8,9 @@
#include "spdlog/details/synchronous_factory.h"
#include <array>
#ifndef SD_JOURNAL_SUPPRESS_LOCATION
#define SD_JOURNAL_SUPPRESS_LOCATION
#endif
#include <systemd/sd-journal.h>
namespace spdlog {
......@@ -63,7 +66,7 @@ protected:
else
{
err = (sd_journal_send)("MESSAGE=%.*s", static_cast<int>(length), msg.payload.data(), "PRIORITY=%d", syslog_level(msg.level),
"SOURCE_FILE=%s", msg.source.filename, "SOURCE_LINE=%d", msg.source.line, "SOURCE_FUNC=%s", msg.source.funcname, nullptr);
"CODE_FILE=%s", msg.source.filename, "CODE_LINE=%d", msg.source.line, "CODE_FUNC=%s", msg.source.funcname, nullptr);
}
if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment