Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace Lua default error print?

Tags:

c++

lua

win32gui

I'm implementing Lua as a script language into a Windows application. Due to the application's structure, printout isn't using streamed io, such as stdout and stderror.

I have managed to override the Lua print to fit into my structure...

lua_register(L,"print", cs_print);

...but how do I override all error an debug printouts without using streams? I need to handle this in a function (similar to print).

like image 866
Max Kielland Avatar asked Mar 21 '23 09:03

Max Kielland


1 Answers

The only place where Lua writes to stderr is in the panic function that luaL_newstate installs. If you're embedding Lua into your application, make sure you start Lua from a protected call and no panic will ever occur. See http://www.lua.org/source/5.2/lua.c.html#main for ideas.

like image 115
lhf Avatar answered Mar 25 '23 03:03

lhf