real_priority = strtoul (err_str + 1, &err_str_prio, 10);
if (err_str_prio && *err_str_prio != '\0') {
- msg_err_pool (
+ msg_err_pool_check (
"cannot parse priority: %s, at symbol %c, error: %s",
line,
*err_str_prio,
}
}
else if (err_str && *err_str != '\0') {
- msg_err_pool (
+ msg_err_pool_check (
"cannot parse port: %s, at symbol %c, error: %s",
line,
*err_str,
freeaddrinfo (res);
}
else {
- msg_err_pool ("address resolution for %s failed: %s",
+ msg_err_pool_check ("address resolution for %s failed: %s",
addr_cpy,
gai_strerror (r));
g_free (addr_cpy);
p = strchr (str, ']');
if (p == NULL) {
- msg_err ("cannot parse address definition %s: %s",
+ msg_err_pool_check ("cannot parse address definition %s: %s",
str,
strerror (EINVAL));
}
if (!rspamd_parse_inet_address (&cur_addr, str, 0)) {
- msg_err_pool ("cannot parse unix socket definition %s: %s",
+ msg_err_pool_check ("cannot parse unix socket definition %s: %s",
str,
strerror (errno));
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, \
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