From: bert hubert Date: Mon, 9 Mar 2015 20:45:36 +0000 (+0100) Subject: implement logging from lua X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~88^2~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c6f43217ccd6923bfb7a39a228603b549c502c0;p=pdns implement logging from lua --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index fb351f814..5ef4048e7 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -325,6 +325,17 @@ vector> setupLua(bool client) g_lua.registerMember("weight", &DownstreamState::weight); g_lua.registerMember("order", &DownstreamState::order); + g_lua.writeFunction("infolog", [](const string& arg) { + infolog("%s", arg); + }); + g_lua.writeFunction("errlog", [](const string& arg) { + errlog("%s", arg); + }); + g_lua.writeFunction("warnlog", [](const string& arg) { + warnlog("%s", arg); + }); + + g_lua.writeFunction("show", [](const string& arg) { g_outputBuffer+=arg; g_outputBuffer+="\n"; diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index a2a80e2a2..40a9008de 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -44,7 +44,6 @@ We neglect to do recvfromto() on 0.0.0.0 Receiver is currently singlethreaded (not that bad actually) lack of help() - we offer no way to log from Lua */ namespace po = boost::program_options; diff --git a/pdns/dnsdistconf.lua b/pdns/dnsdistconf.lua index d77986e2f..995efdd14 100644 --- a/pdns/dnsdistconf.lua +++ b/pdns/dnsdistconf.lua @@ -2,6 +2,8 @@ controlSocket("0.0.0.0") addLocal("0.0.0.0:5200") setKey("MXNeLFWHUe4363BBKrY06cAsH8NWNb+Se2eXU5+Bb74=") +warnlog(string.format("Script starting %s", "up!")) + -- define the good servers newServer("8.8.8.8", 2) -- 2 qps newServer("8.8.4.4", 2)