diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:45:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-07-23 12:45:28 +0100 |
commit | e0483657ff6cf1adc828ccce457814d61fe90a0d (patch) | |
tree | 5183e4163f40b81b3e7d5f51488d360883782154 /src/libutil/logger.h | |
parent | 7962087e808fb824aa3af6d41d02abc92916ba1e (diff) | |
download | rspamd-e0483657ff6cf1adc828ccce457814d61fe90a0d.tar.gz rspamd-e0483657ff6cf1adc828ccce457814d61fe90a0d.zip |
Unify code style.
Diffstat (limited to 'src/libutil/logger.h')
-rw-r--r-- | src/libutil/logger.h | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/src/libutil/logger.h b/src/libutil/logger.h index 4b1c74410..8d4b3763b 100644 --- a/src/libutil/logger.h +++ b/src/libutil/logger.h @@ -1,21 +1,24 @@ #ifndef RSPAMD_LOGGER_H #define RSPAMD_LOGGER_H -#include "config.h" #include "cfg_file.h" +#include "config.h" #include "radix.h" #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 |