lua-users home
lua-l archive

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

On Fri, Mar 27, 2020 at 3:34 PM Russell Haley <> wrote:

On Fri, Mar 27, 2020 at 2:10 PM Roberto Ierusalimschy <> wrote:
> Thoughts (other than 'don't be so lazy')?

Have you looked at PiL (
Yes, thank you. I noted that it calls an error function but the closest I could find was luaL_error.

I also *just* found luaL_pushfstring. Perhaps I'll adapt call_va to use luaL_pushfstring.

Thanks Roberto (and Sean!)
Okay, this seems to work (in 1 out of 1 tested scenarios!):

int wrlog(lua_Integer level, char * format, ...)
char buffer[LOG_STR_SZ];
va_list args;
va_start (args, format);
vsnprintf (buffer,LOG_STR_SZ,format, args);

lua_getglobal(L, "write_log");
lua_pushinteger(L, level);
lua_pushstring(L, (const char*)&buffer);
// return (lua_pcall(L, 2, 0, (void*)NULL));
lua_call(L, 2, 0);
return (0);

Thanks again!


-- Roberto