aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-01 17:41:36 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-01 17:41:36 +0100
commita4fe305046739e4e0a355b5a6e923ebd409acbc6 (patch)
tree25b826a1c047f759fa8ee31d906d23fe3b386de0 /src
parente662595f7d164e2d1884f099195065f975f64ac8 (diff)
downloadrspamd-a4fe305046739e4e0a355b5a6e923ebd409acbc6.tar.gz
rspamd-a4fe305046739e4e0a355b5a6e923ebd409acbc6.zip
Implement conditional debug for modules.
Diffstat (limited to 'src')
-rw-r--r--src/libutil/logger.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/libutil/logger.c b/src/libutil/logger.c
index c3ede99a5..18b4b8d51 100644
--- a/src/libutil/logger.c
+++ b/src/libutil/logger.c
@@ -386,6 +386,23 @@ rspamd_log_flush (rspamd_logger_t *rspamd_log)
}
}
+static inline gboolean
+rspamd_logger_need_log (rspamd_logger_t *rspamd_log, GLogLevelFlags log_level,
+ const gchar *module)
+{
+ g_assert (rspamd_log != NULL);
+
+ if (log_level <= rspamd_log->cfg->log_level) {
+ return TRUE;
+ }
+
+ if (rspamd_log->cfg->debug_modules != NULL && module != NULL &&
+ g_hash_table_lookup (rspamd_log->cfg->debug_modules, module)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
void
rspamd_common_logv (rspamd_logger_t *rspamd_log, GLogLevelFlags log_level,
@@ -406,7 +423,7 @@ rspamd_common_logv (rspamd_logger_t *rspamd_log, GLogLevelFlags log_level,
fprintf (stderr, "%s\n", logbuf);
}
}
- else if (log_level <= rspamd_log->cfg->log_level) {
+ else if (rspamd_logger_need_log (rspamd_log, log_level, module)) {
rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, args);
rspamd_escape_log_string (logbuf);
rspamd_mempool_lock_mutex (rspamd_log->mtx);
@@ -814,7 +831,7 @@ rspamd_conditional_debug (rspamd_logger_t *rspamd_log,
rspamd_log = default_logger;
}
- if (rspamd_log->cfg->log_level >= G_LOG_LEVEL_DEBUG ||
+ if (rspamd_logger_need_log (rspamd_log, G_LOG_LEVEL_DEBUG, module) ||
rspamd_log->is_debug) {
if (rspamd_log->debug_ip && addr != NULL) {
if (radix_find_compressed_addr (rspamd_log->debug_ip, addr)