From b4b9828de50c09fea5503b3b3ead2ae9d5144404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 12 Jan 2018 19:54:14 +0100 Subject: Follow log_level even when using journald output fix #3328 --- src/logger/logger.hpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/logger') diff --git a/src/logger/logger.hpp b/src/logger/logger.hpp index 1689866..315fc11 100644 --- a/src/logger/logger.hpp +++ b/src/logger/logger.hpp @@ -74,8 +74,8 @@ public: bool use_systemd{false}; #endif -private: const int log_level; +private: std::ofstream ofstream{}; std::ostream stream; @@ -105,13 +105,16 @@ namespace logging_details if (Logger::instance()->use_systemd) { (void)level; - std::ostringstream os; - log(os, std::forward(args)...); - sd_journal_send("MESSAGE=%s", os.str().data(), - "PRIORITY=%i", syslog_level, - "CODE_FILE=%s", src_file, - "CODE_LINE=%i", line, - nullptr); + if (level >= Logger::instance()->log_level) + { + std::ostringstream os; + log(os, std::forward(args)...); + sd_journal_send("MESSAGE=%s", os.str().data(), + "PRIORITY=%i", syslog_level, + "CODE_FILE=%s", src_file, + "CODE_LINE=%i", line, + nullptr); + } } else { -- cgit v1.2.3