lua-users home
lua-l archive

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


It was thus said that the Great Marc Balmer once stated:
> > Am 08.05.2020 um 11:04 schrieb Sean Conner <sean@conman.org>:
> > 
> >  And because it hurts me to have to type
> > 
> > 	syslog('warning',string.format("Unit %d is at %s",unit,status))
> > 
> > you can have the syslog function call format for you:
> > 
> > 	static int
> > 	unix_syslog(lua_State *L)
> > 	{
> > 		luaL_checktype(L,1,LUA_TSTRING);

  Oops .. the line above should be

		luaL_checktype(L,2,LUA_TSTRIG);

> > 		lua_getfield(L,2,"format");
> > 		lua_insert(L,2);
> > 		lua_call(L,lua_gettop(L) - 2,1);
> > 		syslog(priorities[luaL_checkoption(L,1,NULL,priority_names)],"%s",lua_tostring(L,-1));
> > 		return 0;
> > 	}

> That's also a good idea.
> 
> Thanks for the feedback!

  You're welcome.

  -spc
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org