lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I'm currently developping a game in which most (read 'all') of the game logic will be scripted in Lua. I have just begun integrating and binding the interpreter to the C code. Specifically, I need to bind the C logging function to lua, so that the game logic can log info through the same channels as the C core.

I've been searching the documentation for information on the performance impact that lua_getstack and lua_getinfo (both called from C code, lua_getinfo with the "Sl" flags) have on a program, in vain: the documentation doesn't say anything about the speed of the C debug api, it only mentions that the lua debug library slows execution down considerably.

So, what sort of speed impact should I expect when calling lua_getstack and lua_getinfo?

(long explanation of what the hell I'm trying to do follows - skip if you can't be bothered :)

My C logging function takes the current file and line number (automagically extracted with a few wrapping macros in the C code) to integrate that info in the log. For the Lua binding, I'd like to use lua_getstack et al. to extract the lua caller source file and line number, so that lua code log lines appear as:

something.lua:42 - Doing this

Instead of:

lua_wrapper.c:193 - Doing this

Therefore, I'd like the C callback of the Lua logging function to extract the Lua caller's file/line info and pass it on to my logging function, so that the logs actually contain useful debug info.

Thanks in advance,
David Anderson