exports.debugm = function(mod, ...)
local logger = require "rspamd_logger"
if unconditional_debug or debug_modules[mod] then
- logger.logx(log_level, ...)
+ logger.logx(log_level, mod, ...)
end
end
const gchar *fmt, va_list args)
{
gchar logbuf[RSPAMD_LOGBUF_SIZE], *end;
- gint level = level_flags & (RSPAMD_LOG_LEVEL_MASK & G_LOG_LEVEL_MASK);
+ gint level = level_flags & (RSPAMD_LOG_LEVEL_MASK & G_LOG_LEVEL_MASK), mod_id;
if (G_UNLIKELY (rspamd_log == NULL)) {
rspamd_log = default_logger;
}
}
else {
- if (rspamd_logger_need_log (rspamd_log, level, -1)) {
+ if (level == G_LOG_LEVEL_DEBUG) {
+ mod_id = rspamd_logger_add_debug_module (module);
+ }
+ else {
+ mod_id = -1;
+ }
+
+ if (rspamd_logger_need_log (rspamd_log, level_flags, mod_id)) {
end = rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, args);
if ((level_flags & RSPAMD_LOG_ENCRYPTED) && rspamd_log->pk) {
LUA_FUNCTION_DEF (logger, slog);
/***
- * @function logger.logx(level, id, fmt[, args)
+ * @function logger.logx(level, module, id, fmt[, args)
* Extended interface to make a generic log message on any level
* @param {number} log level as a number (see GLogLevelFlags enum for values)
* @param {task|cfg|pool|string} id id to log
{
LUA_TRACE_POINT;
GLogLevelFlags flags = lua_tonumber (L, 1);
+ const gchar *modname = lua_tostring (L, 2), *uid = NULL;
+ gchar logbuf[RSPAMD_LOGBUF_SIZE - 128];
+ gboolean ret;
+
+ if (lua_type (L, 3) == LUA_TSTRING) {
+ uid = luaL_checkstring (L, 3);
+ }
+ else {
+ uid = lua_logger_get_id (L, 3, NULL);
+ }
- return lua_logger_do_log (L, flags, FALSE, 2);
+ if (uid && modname && lua_type (L, 4) == LUA_TSTRING) {
+ ret = lua_logger_log_format (L, 4, FALSE, logbuf, sizeof (logbuf) - 1);
+
+ if (ret) {
+ lua_common_log_line (flags, L, logbuf, uid, modname);
+ }
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 0;
}