extern int sc_log_module_cleaned;
-#define SCLog(x, ...) \
+#define SCLog(x, file, func, line, ...) \
do { \
if (sc_log_global_log_level >= x && \
(sc_log_fg_filters_present == 0 || \
- SCLogMatchFGFilterWL(__FILE__, __FUNCTION__, __LINE__) == 1 || \
- SCLogMatchFGFilterBL(__FILE__, __FUNCTION__, __LINE__) == 1) && \
+ SCLogMatchFGFilterWL(file, func, line) == 1 || \
+ SCLogMatchFGFilterBL(file, func, line) == 1) && \
(sc_log_fd_filters_present == 0 || \
- SCLogMatchFDFilter(__FUNCTION__) == 1)) \
+ SCLogMatchFDFilter(func) == 1)) \
{ \
char _sc_log_msg[SC_LOG_MAX_LOG_MSG_LEN]; \
\
snprintf(_sc_log_msg, SC_LOG_MAX_LOG_MSG_LEN, __VA_ARGS__); \
\
- SCLogMessage(x, \
- __FILE__, \
- __LINE__, \
- __FUNCTION__, SC_OK, _sc_log_msg); \
+ SCLogMessage(x, file, line, func, SC_OK, _sc_log_msg); \
} \
} while(0)
-#define SCLogErr(x, err, ...) \
+#define SCLogErr(x, file, func, line, err, ...) \
do { \
if (sc_log_global_log_level >= x && \
(sc_log_fg_filters_present == 0 || \
- SCLogMatchFGFilterWL(__FILE__, __FUNCTION__, __LINE__) == 1 || \
- SCLogMatchFGFilterBL(__FILE__, __FUNCTION__, __LINE__) == 1) && \
+ SCLogMatchFGFilterWL(file, func, line) == 1 || \
+ SCLogMatchFGFilterBL(file, func, line) == 1) && \
(sc_log_fd_filters_present == 0 || \
- SCLogMatchFDFilter(__FUNCTION__) == 1)) \
+ SCLogMatchFDFilter(func) == 1)) \
{ \
char _sc_log_msg[SC_LOG_MAX_LOG_MSG_LEN]; \
\
snprintf(_sc_log_msg, SC_LOG_MAX_LOG_MSG_LEN, __VA_ARGS__); \
\
- SCLogMessage(x, \
- __FILE__, \
- __LINE__, \
- __FUNCTION__, err, _sc_log_msg); \
+ SCLogMessage(x, file, line, func, err, _sc_log_msg); \
} \
} while(0)
*
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogInfo(...) SCLog(SC_LOG_INFO, __VA_ARGS__)
+#define SCLogInfo(...) SCLog(SC_LOG_INFO, \
+ __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
+#define SCLogInfoRaw(file, func, line, ...) SCLog(SC_LOG_INFO, \
+ (file), (func), (line), __VA_ARGS__)
/**
* \brief Macro used to log NOTICE messages.
*
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogNotice(...) SCLog(SC_LOG_NOTICE, __VA_ARGS__)
+#define SCLogNotice(...) SCLog(SC_LOG_NOTICE, \
+ __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
+#define SCLogNoticeRaw(file, func, line, ... ) SCLog(SC_LOG_NOTICE, \
+ (file), (func), (line), __VA_ARGS__)
/**
* \brief Macro used to log WARNING messages.
* warning message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogWarning(err_code, ...) SCLogErr(SC_LOG_WARNING, err_code, \
- __VA_ARGS__)
+#define SCLogWarning(err_code, ...) SCLogErr(SC_LOG_WARNING, \
+ __FILE__, __FUNCTION__, __LINE__, \
+ err_code, __VA_ARGS__)
+#define SCLogWarningRaw(err_code, file, func, line, ...) \
+ SCLogErr(SC_LOG_WARNING, (file), (func), (line), err_code, __VA_ARGS__)
+
/**
* \brief Macro used to log ERROR messages.
*
* error message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \
- __VA_ARGS__)
+#define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, \
+ __FILE__, __FUNCTION__, __LINE__, \
+ err_code, __VA_ARGS__)
+#define SCLogErrorRaw(err_code, file, func, line, ...) SCLogErr(SC_LOG_ERROR, \
+ (file), (func), (line), err_code, __VA_ARGS__)
+
/**
* \brief Macro used to log CRITICAL messages.
*
* critical message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogCritical(err_code, ...) SCLogErr(SC_LOG_CRITICAL, err_code, \
- __VA_ARGS__)
+#define SCLogCritical(err_code, ...) SCLogErr(SC_LOG_CRITICAL, \
+ __FILE__, __FUNCTION__, __LINE__, \
+ err_code, __VA_ARGS__)
/**
* \brief Macro used to log ALERT messages.
*
* alert message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogAlert(err_code, ...) SCLogErr(SC_LOG_ALERT, err_code, \
- __VA_ARGS__)
+#define SCLogAlert(err_code, ...) SCLogErr(SC_LOG_ALERT, \
+ __FILE__, __FUNCTION__, __LINE__, \
+ err_code, __VA_ARGS__)
/**
* \brief Macro used to log EMERGENCY messages.
*
* emergency message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogEmerg(err_code, ...) SCLogErr(SC_LOG_EMERGENCY, err_code, \
- __VA_ARGS__)
+#define SCLogEmerg(err_code, ...) SCLogErr(SC_LOG_EMERGENCY, \
+ __FILE__, __FUNCTION__, __LINE__, \
+ err_code, __VA_ARGS__)
/* Avoid the overhead of using the debugging subsystem, in production mode */
*
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogDebug(...) SCLog(SC_LOG_DEBUG, __VA_ARGS__)
+#define SCLogDebug(...) SCLog(SC_LOG_DEBUG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
/**
* \brief Macro used to log debug messages on function entry. Comes under the
const char *msg = LuaGetStringArgument(luastate, 1);
if (msg == NULL)
return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
- SCLogInfo("%s", msg);
+
+ lua_Debug ar;
+ lua_getstack(luastate, 1, &ar);
+ lua_getinfo(luastate, "nSl", &ar);
+ const char *funcname = ar.name ? ar.name : ar.what;
+ SCLogInfoRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
return 0;
}
const char *msg = LuaGetStringArgument(luastate, 1);
if (msg == NULL)
return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
- SCLogNotice("%s", msg);
+
+ lua_Debug ar;
+ lua_getstack(luastate, 1, &ar);
+ lua_getinfo(luastate, "nSl", &ar);
+ const char *funcname = ar.name ? ar.name : ar.what;
+ SCLogNoticeRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
return 0;
}
const char *msg = LuaGetStringArgument(luastate, 1);
if (msg == NULL)
return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
- SCLogWarning(SC_WARN_LUA_SCRIPT, "%s", msg);
+
+ lua_Debug ar;
+ lua_getstack(luastate, 1, &ar);
+ lua_getinfo(luastate, "nSl", &ar);
+ const char *funcname = ar.name ? ar.name : ar.what;
+ SCLogWarningRaw(SC_WARN_LUA_SCRIPT, ar.short_src, funcname, ar.currentline, "%s", msg);
return 0;
}
const char *msg = LuaGetStringArgument(luastate, 1);
if (msg == NULL)
return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
- SCLogError(SC_ERR_LUA_SCRIPT, "%s", msg);
+ lua_Debug ar;
+ lua_getstack(luastate, 1, &ar);
+ lua_getinfo(luastate, "nSl", &ar);
+ const char *funcname = ar.name ? ar.name : ar.what;
+ SCLogErrorRaw(SC_ERR_LUA_SCRIPT, ar.short_src, funcname, ar.currentline, "%s", msg);
return 0;
}