diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-12-06 13:10:31 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-12-06 13:10:31 +0000 |
commit | a7e98226be0a25c1342720e97b7c6841c2e14eb5 (patch) | |
tree | 84072514918fa54b4082ae36416597c0e773eae6 /src | |
parent | 1bd9b9af8556f1c7e107f703304923361056d3d0 (diff) | |
download | rspamd-a7e98226be0a25c1342720e97b7c6841c2e14eb5.tar.gz rspamd-a7e98226be0a25c1342720e97b7c6841c2e14eb5.zip |
[Minor] Allow to log numeric id
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/logger.c | 36 | ||||
-rw-r--r-- | src/libutil/logger.h | 8 |
2 files changed, 43 insertions, 1 deletions
diff --git a/src/libutil/logger.c b/src/libutil/logger.c index 193dd4fce..4fc14c550 100644 --- a/src/libutil/logger.c +++ b/src/libutil/logger.c @@ -1368,6 +1368,42 @@ rspamd_conditional_debug_fast (rspamd_logger_t *rspamd_log, } } +void +rspamd_conditional_debug_fast_num_id (rspamd_logger_t *rspamd_log, + rspamd_inet_addr_t *addr, + guint mod_id, const gchar *module, guint64 id, + const gchar *function, const gchar *fmt, ...) +{ + static gchar logbuf[LOGBUF_LEN], idbuf[64]; + va_list vp; + gchar *end; + + if (rspamd_log == NULL) { + rspamd_log = default_logger; + } + + if (rspamd_logger_need_log (rspamd_log, G_LOG_LEVEL_DEBUG, mod_id) || + rspamd_log->is_debug) { + if (rspamd_log->debug_ip && addr != NULL) { + if (rspamd_match_radix_map_addr (rspamd_log->debug_ip, addr) + == NULL) { + return; + } + } + + rspamd_snprintf (idbuf, sizeof (idbuf), "%XuL", id); + va_start (vp, fmt); + end = rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, vp); + *end = '\0'; + va_end (vp); + rspamd_log->log_func (module, idbuf, + function, + G_LOG_LEVEL_DEBUG | RSPAMD_LOG_FORCED, + logbuf, + rspamd_log); + } +} + /** * Wrapper for glib logger */ diff --git a/src/libutil/logger.h b/src/libutil/logger.h index 1dff75211..dd980445e 100644 --- a/src/libutil/logger.h +++ b/src/libutil/logger.h @@ -133,7 +133,13 @@ void rspamd_conditional_debug (rspamd_logger_t *logger, void rspamd_conditional_debug_fast (rspamd_logger_t *logger, rspamd_inet_addr_t *addr, - guint mod_id, const gchar *module, const gchar *id, + guint mod_id, + const gchar *module, const gchar *id, + const gchar *function, const gchar *fmt, ...); +void rspamd_conditional_debug_fast_num_id (rspamd_logger_t *logger, + rspamd_inet_addr_t *addr, + guint mod_id, + const gchar *module, guint64 id, const gchar *function, const gchar *fmt, ...); /** |