Comparison

util-src/pposix.c @ 729:f62ef65d5c01

pposix: Add syslog_setmask (use config: minimum_log_level = 'warn' etc.)
author Matthew Wild <mwild1@gmail.com>
date Fri, 16 Jan 2009 05:20:04 +0000
parent 727:78c9542de94e
child 730:ac951c44751c
comparison
equal deleted inserted replaced
728:fa45dfb27ee5 729:f62ef65d5c01
201 syslog_ident = NULL; 201 syslog_ident = NULL;
202 } 202 }
203 return 0; 203 return 0;
204 } 204 }
205 205
206 int lc_syslog_setmask(lua_State* L)
207 {
208 int level_idx = luaL_checkoption(L, 1, "notice", &level_strings);
209 int mask = 0;
210 do
211 {
212 printf("PPOSIX: Setting mask for %s\n", level_strings[level_idx]);
213 mask |= LOG_MASK(level_constants[level_idx]);
214 } while (++level_idx<=4);
215
216 setlogmask(mask);
217 return 0;
218 }
219
206 /* getpid */ 220 /* getpid */
207 221
208 int lc_getpid(lua_State* L) 222 int lc_getpid(lua_State* L)
209 { 223 {
210 lua_pushinteger(L, getpid()); 224 lua_pushinteger(L, getpid());
227 lua_setfield(L, -2, "syslog_close"); 241 lua_setfield(L, -2, "syslog_close");
228 242
229 lua_pushcfunction(L, lc_syslog_log); 243 lua_pushcfunction(L, lc_syslog_log);
230 lua_setfield(L, -2, "syslog_log"); 244 lua_setfield(L, -2, "syslog_log");
231 245
246 lua_pushcfunction(L, lc_syslog_setmask);
247 lua_setfield(L, -2, "syslog_setminlevel");
248
232 lua_pushcfunction(L, lc_getpid); 249 lua_pushcfunction(L, lc_getpid);
233 lua_setfield(L, -2, "getpid"); 250 lua_setfield(L, -2, "getpid");
234 251
235 lua_pushliteral(L, "pposix"); 252 lua_pushliteral(L, "pposix");
236 lua_setfield(L, -2, "_NAME"); 253 lua_setfield(L, -2, "_NAME");