diff options
Diffstat (limited to 'src/libutil/logger.h')
-rw-r--r-- | src/libutil/logger.h | 78 |
1 files changed, 57 insertions, 21 deletions
diff --git a/src/libutil/logger.h b/src/libutil/logger.h index 4b1c74410..078180b86 100644 --- a/src/libutil/logger.h +++ b/src/libutil/logger.h @@ -7,15 +7,18 @@ #include "util.h" -typedef void (*rspamd_log_func_t)(const gchar * log_domain, const gchar *function, - GLogLevelFlags log_level, const gchar * message, - gboolean forced, gpointer arg); +typedef void (*rspamd_log_func_t)(const gchar * log_domain, + const gchar *function, + GLogLevelFlags log_level, const gchar * message, + gboolean forced, gpointer arg); typedef struct rspamd_logger_s rspamd_logger_t; /** * Init logger */ -void rspamd_set_logger (struct rspamd_config *cfg, GQuark ptype, struct rspamd_main *main); +void rspamd_set_logger (struct rspamd_config *cfg, + GQuark ptype, + struct rspamd_main *main); /** * Open log file or initialize other structures */ @@ -55,28 +58,33 @@ void flush_log_buf (rspamd_logger_t *logger); * Log function that is compatible for glib messages */ void rspamd_glib_log_function (const gchar *log_domain, - GLogLevelFlags log_level, const gchar *message, gpointer arg); + GLogLevelFlags log_level, const gchar *message, gpointer arg); /** * Function with variable number of arguments support */ void rspamd_common_log_function (rspamd_logger_t *logger, - GLogLevelFlags log_level, const gchar *function, const gchar *fmt, ...); + GLogLevelFlags log_level, const gchar *function, const gchar *fmt, ...); void rspamd_common_logv (rspamd_logger_t *logger, - GLogLevelFlags log_level, const gchar *function, const gchar *fmt, va_list args); + GLogLevelFlags log_level, + const gchar *function, + const gchar *fmt, + va_list args); /** * Conditional debug function */ void rspamd_conditional_debug (rspamd_logger_t *logger, - rspamd_inet_addr_t *addr, const gchar *function, const gchar *fmt, ...) ; + rspamd_inet_addr_t *addr, const gchar *function, const gchar *fmt, ...); /** * Function with variable number of arguments support that uses static default logger */ -void rspamd_default_log_function (GLogLevelFlags log_level, const gchar *function, - const gchar *fmt, ...); +void rspamd_default_log_function (GLogLevelFlags log_level, + const gchar *function, + const gchar *fmt, + ...); /** * Varargs version of default log function @@ -85,7 +93,10 @@ void rspamd_default_log_function (GLogLevelFlags log_level, const gchar *functio * @param fmt * @param args */ -void rspamd_default_logv (GLogLevelFlags log_level, const gchar *function, const gchar *fmt, va_list args); +void rspamd_default_logv (GLogLevelFlags log_level, + const gchar *function, + const gchar *fmt, + va_list args); /** * Temporary turn on debug @@ -101,17 +112,42 @@ void rspamd_log_nodebug (rspamd_logger_t *logger); /* Logging in postfix style */ #if defined(RSPAMD_MAIN) -#define msg_err(...) rspamd_common_log_function(rspamd_main->logger, G_LOG_LEVEL_CRITICAL, __FUNCTION__, __VA_ARGS__) -#define msg_warn(...) rspamd_common_log_function(rspamd_main->logger, G_LOG_LEVEL_WARNING, __FUNCTION__, __VA_ARGS__) -#define msg_info(...) rspamd_common_log_function(rspamd_main->logger, G_LOG_LEVEL_INFO, __FUNCTION__, __VA_ARGS__) -#define msg_debug(...) rspamd_conditional_debug(rspamd_main->logger, NULL, __FUNCTION__, __VA_ARGS__) -#define debug_task(...) rspamd_conditional_debug(rspamd_main->logger, &task->from_addr, __FUNCTION__, __VA_ARGS__) +#define msg_err(...) rspamd_common_log_function (rspamd_main->logger, \ + G_LOG_LEVEL_CRITICAL, \ + __FUNCTION__, \ + __VA_ARGS__) +#define msg_warn(...) rspamd_common_log_function (rspamd_main->logger, \ + G_LOG_LEVEL_WARNING, \ + __FUNCTION__, \ + __VA_ARGS__) +#define msg_info(...) rspamd_common_log_function (rspamd_main->logger, \ + G_LOG_LEVEL_INFO, \ + __FUNCTION__, \ + __VA_ARGS__) +#define msg_debug(...) rspamd_conditional_debug (rspamd_main->logger, \ + NULL, \ + __FUNCTION__, \ + __VA_ARGS__) +#define debug_task(...) rspamd_conditional_debug (rspamd_main->logger, \ + &task->from_addr, \ + __FUNCTION__, \ + __VA_ARGS__) #else -#define msg_err(...) rspamd_default_log_function(G_LOG_LEVEL_CRITICAL, __FUNCTION__, __VA_ARGS__) -#define msg_warn(...) rspamd_default_log_function(G_LOG_LEVEL_WARNING, __FUNCTION__, __VA_ARGS__) -#define msg_info(...) rspamd_default_log_function(G_LOG_LEVEL_INFO, __FUNCTION__, __VA_ARGS__) -#define msg_debug(...) rspamd_default_log_function(G_LOG_LEVEL_DEBUG, __FUNCTION__, __VA_ARGS__) -#define debug_task(...) rspamd_default_log_function(G_LOG_LEVEL_DEBUG, __FUNCTION__, __VA_ARGS__) +#define msg_err(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ + __FUNCTION__, \ + __VA_ARGS__) +#define msg_warn(...) rspamd_default_log_function (G_LOG_LEVEL_WARNING, \ + __FUNCTION__, \ + __VA_ARGS__) +#define msg_info(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \ + __FUNCTION__, \ + __VA_ARGS__) +#define msg_debug(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ + __FUNCTION__, \ + __VA_ARGS__) +#define debug_task(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ + __FUNCTION__, \ + __VA_ARGS__) #endif #endif |