aboutsummaryrefslogtreecommitdiff
path: root/src/lua/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/log.c')
-rw-r--r--src/lua/log.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/lua/log.c b/src/lua/log.c
index 2b6d068..ee85369 100644
--- a/src/lua/log.c
+++ b/src/lua/log.c
@@ -18,12 +18,7 @@ static void lua_log_debuginfo(lua_State *state, const char **module, const char
lua_pushnumber(state, 2);
// S: source, l: currentline, n: name
- const char *query =
-#ifdef _RELEASE
- "Sl";
-#else
- "Sln";
-#endif
+ const char *query = "Sln";
lua_pushstring(state, query);
if (lua_pcall(state, 2, 1, 0) == LUA_OK) {
@@ -33,21 +28,21 @@ static void lua_log_debuginfo(lua_State *state, const char **module, const char
lua_getfield(state, -2, "currentline");
int line = lua_tointeger(state, -1);
-#ifndef _RELEASE
lua_getfield(state, -3, "name");
const char *name = lua_tostring(state, -1);
- if (name)
- *func = name;
-#endif
if (!strncmp(shortsrc, "[string ", 8)) {
int length = strlen(shortsrc);
snprintf(buffer, size, "%.*s", length - 9, shortsrc + 8);
+
+ *func = buffer;
+ *module = "lua";
} else {
snprintf(buffer, size, "%s:%d", shortsrc, line);
- }
- *module = buffer;
+ *func = name ? name : "?";
+ *module = buffer;
+ }
} else {
log_trace("Failed to retrieve Lua debug information");
}
@@ -70,11 +65,11 @@ static int lua_log_wrapper(lua_State *state, int skip_args, any_log_level_t leve
lua_call(state, n_args, 1);
const char *message = lua_tostring(state, -1);
- const char *module = "?", *func = "";
+ const char *module, *func;
char buffer[4096];
lua_log_debuginfo(state, &module, &func, buffer, sizeof(buffer));
- any_log_format(level, "lua", module, func, "%s", message);
+ any_log_format(level, module, func, "%s", message);
return 0;
}
@@ -122,11 +117,11 @@ static int lua_log_wrapperv(lua_State *state, any_log_level_t level)
lua_remove(state, 1);
luaL_checktype(state, 1, LUA_TTABLE);
- const char *module = "?", *func = "";
+ const char *module, *func;
char buffer[4096];
lua_log_debuginfo(state, &module, &func, buffer, sizeof(buffer));
- any_log_value(level, "lua", module, func, message,
+ any_log_value(level, module, func, message,
"g:value", ANY_LOG_FORMATTER(lua_print_value), state,
NULL);
return 0;
@@ -206,7 +201,7 @@ void lua_print_value_at(FILE *stream, lua_State *state, int index)
first = false;
if (lua_isnumber(state, -2)) {
- fprintf(stream, "[%lld] = ", lua_tointeger(state, -2));
+ fprintf(stream, "[%ld] = ", lua_tointeger(state, -2));
} else {
fprintf(stream, "%s = ", lua_tostring(state, -2));
}