Changeset a1327f81600be8f035da9679d8488d1d67072eb4

Show
Ignore:
Timestamp:
08/15/08 19:33:12 (10 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1218828792 +0000
git-parent:

[00082387f91bd61e4cc183f2e307a5f7b05e4b79]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1218828792 +0000
Message:

fixes #55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/lua_noit.c

    r0008238 ra1327f8  
    463463 
    464464static int 
     465nl_log(lua_State *L) { 
     466  int i, n; 
     467  const char *log_dest, *message; 
     468  noit_log_stream_t ls; 
     469 
     470  log_dest = lua_tostring(L, 1); 
     471  ls = noit_log_stream_find(log_dest); 
     472  if(!ls) { 
     473    noitL(noit_stderr, "Cannot find log stream: '%s'\n", log_dest); 
     474    return 0; 
     475  } 
     476 
     477  n = lua_gettop(L); 
     478  lua_pushstring(L, "string"); 
     479  lua_gettable(L, LUA_GLOBALSINDEX); 
     480  lua_pushstring(L, "format"); 
     481  lua_gettable(L, -1); 
     482  for(i=2;i<=n;i++) 
     483    lua_pushvalue(L, i); 
     484  lua_call(L, n-1, 1); 
     485  message = lua_tostring(L, -1); 
     486  noitL(ls, "%s", message); 
     487  lua_pop(L, 1); /* formatted string */ 
     488  lua_pop(L, 1); /* "string" table */ 
     489  return 0; 
     490} 
     491static int 
    465492nl_socket_tcp(lua_State *L, int family) { 
    466493  struct nl_slcl *cl; 
     
    515542  { "sleep", nl_sleep }, 
    516543  { "socket", nl_socket }, 
     544  { "log", nl_log }, 
    517545  { "socket_ipv6", nl_socket_ipv6 }, 
    518546  { NULL, NULL }