summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-01-12 19:54:14 +0100
committerlouiz’ <louiz@louiz.org>2018-01-12 20:08:15 +0100
commitb4b9828de50c09fea5503b3b3ead2ae9d5144404 (patch)
tree25c846212f90d1ecefb71c32e1cd56ecb4803a4c
parent34d6c2bce1f9f3236992660e0c0458e5cc8eb74d (diff)
downloadbiboumi-b4b9828de50c09fea5503b3b3ead2ae9d5144404.tar.gz
biboumi-b4b9828de50c09fea5503b3b3ead2ae9d5144404.tar.bz2
biboumi-b4b9828de50c09fea5503b3b3ead2ae9d5144404.tar.xz
biboumi-b4b9828de50c09fea5503b3b3ead2ae9d5144404.zip
Follow log_level even when using journald output
fix #3328
-rw-r--r--CHANGELOG.rst2
-rw-r--r--src/logger/logger.hpp19
2 files changed, 13 insertions, 8 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 76296b6..76be951 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -10,6 +10,8 @@ Version 7.0
would ignore our messages entirely.
- Fix the iq result sent at the end of a MAM response. Some clients (e.g.
gajim) would throw an error as a result.
+- log_level configuration option is no longer ignored if the logs are written
+ into journald
Sqlite3 to PostgreSQL migration
-------------------------------
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<U>(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<U>(args)...);
+ sd_journal_send("MESSAGE=%s", os.str().data(),
+ "PRIORITY=%i", syslog_level,
+ "CODE_FILE=%s", src_file,
+ "CODE_LINE=%i", line,
+ nullptr);
+ }
}
else
{