diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-24 23:31:45 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-24 23:31:45 +0000 |
commit | a7e9c6c403bde957b8f07895bb2f7f2b13135fb0 (patch) | |
tree | 703c6d5a8bfc859ad70f89016e78632c667ff66b /src/libutil/logger.h | |
parent | d100debaa37a7477fa06bb95ca5087ed70f99cba (diff) | |
download | rspamd-a7e9c6c403bde957b8f07895bb2f7f2b13135fb0.tar.gz rspamd-a7e9c6c403bde957b8f07895bb2f7f2b13135fb0.zip |
Add logging macroes with guards
Diffstat (limited to 'src/libutil/logger.h')
-rw-r--r-- | src/libutil/logger.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libutil/logger.h b/src/libutil/logger.h index 42307fc6c..7bf8307c8 100644 --- a/src/libutil/logger.h +++ b/src/libutil/logger.h @@ -174,6 +174,23 @@ const guint64* rspamd_log_counters (rspamd_logger_t *logger); task->task_pool->tag.tagname, task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +/* Check for NULL pointer first */ +#define msg_err_task_check(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ + task ? task->task_pool->tag.tagname : NULL, task ? task->task_pool->tag.uid : NULL, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_warn_task_check(...) rspamd_default_log_function (G_LOG_LEVEL_WARNING, \ + task ? task->task_pool->tag.tagname : NULL, task ? task->task_pool->tag.uid : NULL, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_info_task_check(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \ + task ? task->task_pool->tag.tagname : NULL, task ? task->task_pool->tag.uid : NULL, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_debug_task_check(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ + task ? task->task_pool->tag.tagname : NULL, task ? task->task_pool->tag.uid : NULL, \ + G_STRFUNC, \ + __VA_ARGS__) /* Use the following macros if you have `pool` in the function */ #define msg_err_pool(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ @@ -192,4 +209,21 @@ const guint64* rspamd_log_counters (rspamd_logger_t *logger); pool->tag.tagname, pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +/* Check for NULL pointer first */ +#define msg_err_pool_check(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ + pool ? pool->tag.tagname : NULL, pool ? pool->tag.uid : NULL, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_warn_pool_check(...) rspamd_default_log_function (G_LOG_LEVEL_WARNING, \ + pool ? pool->tag.tagname : NULL, pool ? pool->tag.uid : NULL, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_info_pool_check(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \ + pool ? pool->tag.tagname : NULL, pool ? pool->tag.uid : NULL, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_debug_pool_check(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ + pool ? pool->tag.tagname : NULL, pool ? pool->tag.uid : NULL, \ + G_STRFUNC, \ + __VA_ARGS__) #endif |