From cd169795faeebbbf799bf3334697dc302c1c084f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 17 Feb 2018 11:38:46 +0000 Subject: [Fix] Switch rspamadm logging to message level --- src/lua/lua_logger.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/lua') 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) { -- cgit v1.2.3