Skip to content

Commit

Permalink
Add stack traces on Lua warnings
Browse files Browse the repository at this point in the history
This means that any deprecation message triggered from Lua now explains exactly where it triggered.

The message still triggers only once, so you would need multiple passes to fix every case, but it seems like an improvement.
  • Loading branch information
CelticMinstrel committed Feb 17, 2021
1 parent 49d0382 commit a87d1a0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/scripting/lua_kernel_base.cpp
Expand Up @@ -135,8 +135,13 @@ static void impl_warn(void* p, const char* msg, int tocont) {
warning.seekp(0, std::ios::end);
warning << msg << ' ';
if(!tocont) {
auto& lk = lua_kernel_base::get_lua_kernel<lua_kernel_base>(reinterpret_cast<lua_State*>(p));
lk.add_log_to_console(warning.str());
auto L = reinterpret_cast<lua_State*>(p);
luaW_getglobal(L, "debug", "traceback");
lua_push(L, warning.str());
lua_pushinteger(L, 2);
lua_call(L, 2, 1);
auto& lk = lua_kernel_base::get_lua_kernel<lua_kernel_base>(L);
lk.add_log_to_console(luaL_checkstring(L, -1));
warning.str(prefix);
}
}
Expand Down

0 comments on commit a87d1a0

Please sign in to comment.