From cd169795faeebbbf799bf3334697dc302c1c084f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 17 Feb 2018 11:38:46 +0000 Subject: [PATCH] [Fix] Switch rspamadm logging to message level --- src/libutil/logger.h | 8 ++++++++ src/lua/lua_logger.c | 32 ++++++++++++++++++++++++++++++++ src/rspamadm/rspamadm.c | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/libutil/logger.h b/src/libutil/logger.h index 9b94c03ee..e48e1161a 100644 --- a/src/libutil/logger.h +++ b/src/libutil/logger.h @@ -200,6 +200,10 @@ extern guint rspamd_task_log_id; NULL, NULL, \ G_STRFUNC, \ __VA_ARGS__) +#define msg_notice(...) rspamd_default_log_function (G_LOG_LEVEL_MESSAGE, \ + NULL, NULL, \ + G_STRFUNC, \ + __VA_ARGS__) #define msg_debug(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ NULL, NULL, \ G_STRFUNC, \ @@ -220,6 +224,10 @@ extern guint rspamd_task_log_id; task->task_pool->tag.tagname, task->task_pool->tag.uid, \ G_STRFUNC, \ __VA_ARGS__) +#define msg_notice_task(...) rspamd_default_log_function (G_LOG_LEVEL_MESSAGE, \ + task->task_pool->tag.tagname, task->task_pool->tag.uid, \ + G_STRFUNC, \ + __VA_ARGS__) #define msg_info_task(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \ task->task_pool->tag.tagname, task->task_pool->tag.uid, \ G_STRFUNC, \ diff --git a/src/lua/lua_logger.c b/src/lua/lua_logger.c index da950030d..65461a655 100644 --- a/src/lua/lua_logger.c +++ b/src/lua/lua_logger.c @@ -74,6 +74,12 @@ LUA_FUNCTION_DEF (logger, warn); * @param {string} msg string to be logged */ LUA_FUNCTION_DEF (logger, info); +/*** + * @function logger.message(msg) + * Log message as an notice message + * @param {string} msg string to be logged + */ +LUA_FUNCTION_DEF (logger, message); /*** * @function logger.debug(msg) * Log message as a debug message @@ -101,6 +107,13 @@ LUA_FUNCTION_DEF (logger, warnx); * @param {any} args list of arguments to be replaced in % positions */ LUA_FUNCTION_DEF (logger, infox); +/*** + * @function logger.infox(fmt[, args) + * Extended interface to make an informational log message + * @param {string} fmt format string, arguments are encoded as % + * @param {any} args list of arguments to be replaced in % positions + */ +LUA_FUNCTION_DEF (logger, messagex); /*** * @function logger.debugx(fmt[, args) * Extended interface to make a debug log message @@ -130,11 +143,15 @@ LUA_FUNCTION_DEF (logger, slog); static const struct luaL_reg loggerlib_f[] = { LUA_INTERFACE_DEF (logger, err), LUA_INTERFACE_DEF (logger, warn), + LUA_INTERFACE_DEF (logger, message), + {"msg", lua_logger_message}, LUA_INTERFACE_DEF (logger, info), LUA_INTERFACE_DEF (logger, debug), LUA_INTERFACE_DEF (logger, errx), LUA_INTERFACE_DEF (logger, warnx), LUA_INTERFACE_DEF (logger, infox), + LUA_INTERFACE_DEF (logger, messagex), + {"msgx", lua_logger_messagex}, LUA_INTERFACE_DEF (logger, debugx), LUA_INTERFACE_DEF (logger, debugm), LUA_INTERFACE_DEF (logger, slog), @@ -236,6 +253,15 @@ lua_logger_info (lua_State *L) return 0; } +static gint +lua_logger_message (lua_State *L) +{ + const gchar *msg; + msg = luaL_checkstring (L, 1); + lua_common_log_line (G_LOG_LEVEL_MESSAGE, L, msg, NULL, NULL); + return 0; +} + static gint lua_logger_debug (lua_State *L) { @@ -711,6 +737,12 @@ lua_logger_infox (lua_State *L) return lua_logger_logx (L, G_LOG_LEVEL_INFO, FALSE); } +static gint +lua_logger_messagex (lua_State *L) +{ + return lua_logger_logx (L, G_LOG_LEVEL_MESSAGE, FALSE); +} + static gint lua_logger_debugx (lua_State *L) { diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c index 51c621744..c42a76a09 100644 --- a/src/rspamadm/rspamadm.c +++ b/src/rspamadm/rspamadm.c @@ -297,7 +297,7 @@ main (gint argc, gchar **argv, gchar **env) cfg->log_level = G_LOG_LEVEL_DEBUG; } else { - cfg->log_level = G_LOG_LEVEL_INFO; + cfg->log_level = G_LOG_LEVEL_MESSAGE; } cfg->log_type = RSPAMD_LOG_CONSOLE; -- 2.39.5