From 52f96b9fd1a358956b0331e3e194c8a752d2ee5a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 16 Jul 2012 16:02:14 -0700 Subject: [PATCH] log: apply log_level to stderr/syslog logic In non-crash situations, we want to make sure the message is both below the syslog/stderr threshold and also below the normal log threshold. Otherwise we get anything we gather on those channels, even when the log level is low. Signed-off-by: Sage Weil --- src/log/Log.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/log/Log.cc b/src/log/Log.cc index f029390f5a5e5..7c54534b0b4e5 100644 --- a/src/log/Log.cc +++ b/src/log/Log.cc @@ -188,9 +188,12 @@ void Log::_flush(EntryQueue *t, EntryQueue *requeue, bool crash) while ((e = t->dequeue()) != NULL) { unsigned sub = e->m_subsys; - bool do_fd = m_fd >= 0 && (crash || m_subs->get_log_level(sub) >= e->m_prio); - bool do_syslog = (crash ? m_syslog_crash : m_syslog_log) >= e->m_prio; - bool do_stderr = (crash ? m_stderr_crash : m_stderr_log) >= e->m_prio; + bool should_log = m_subs->get_log_level(sub) >= e->m_prio; + bool do_fd = m_fd >= 0 && (crash || should_log); + bool do_syslog = crash ? (m_syslog_crash >= e->m_prio) : + (m_syslog_crash >= e->m_prio && should_log); + bool do_stderr = crash ? (m_stderr_crash >= e->m_prio) : + (m_stderr_crash >= e->m_prio && should_log); if (do_fd || do_syslog || do_stderr) { int buflen = 0; -- 2.39.5