end
-- Debugging support
-local unconditional_debug = false
+local logger = require "rspamd_logger"
+local unconditional_debug = logger.log_level() == 'debug'
local debug_modules = {}
local debug_aliases = {}
local log_level = 384 -- debug + forced (1 << 7 | 1 << 8)
exports.init_debug_logging = function(config)
- local logger = require "rspamd_logger"
-- Fill debug modules from the config
- local logging = config:get_all_opt('logging')
- if logging then
- local log_level_str = logging.level
- if log_level_str then
- if log_level_str == 'debug' then
- unconditional_debug = true
+ if not unconditional_debug then
+ local log_config = config:get_all_opt('logging')
+ if log_config then
+ local log_level_str = log_config.level
+ if log_level_str then
+ if log_level_str == 'debug' then
+ unconditional_debug = true
+ end
end
- end
-
- if not unconditional_debug then
- if logging.debug_modules then
- for _,m in ipairs(logging.debug_modules) do
+ if log_config.debug_modules then
+ for _,m in ipairs(log_config.debug_modules) do
debug_modules[m] = true
logger.infox(config, 'enable debug for Lua module %s', m)
end
* @param level
*/
void rspamd_log_set_log_level (rspamd_logger_t *logger, gint level);
+gint rspamd_log_get_log_level (rspamd_logger_t *logger);
+const gchar *rspamd_get_log_severity_string(gint level_flags);
/**
* Set log flags (from enum rspamd_log_flags)
* @param logger
*/
LUA_FUNCTION_DEF (logger, logx);
+/***
+ * @function logger.log_level()
+ * Returns log level for a logger
+ * @return {string} current log level
+ */
+LUA_FUNCTION_DEF (logger, log_level);
+
static const struct luaL_reg loggerlib_f[] = {
LUA_INTERFACE_DEF (logger, err),
LUA_INTERFACE_DEF (logger, warn),
LUA_INTERFACE_DEF (logger, debugm),
LUA_INTERFACE_DEF (logger, slog),
LUA_INTERFACE_DEF (logger, logx),
+ LUA_INTERFACE_DEF (logger, log_level),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
return lua_logger_do_log (L, 0, TRUE, 1);
}
+static gint
+lua_logger_log_level (lua_State *L)
+{
+ gint log_level = rspamd_log_get_log_level (NULL);
+
+ lua_pushstring (L, rspamd_get_log_severity_string(log_level));
+
+ return 1;
+}
+
/*** Init functions ***/
static gint