From: bert hubert Date: Sun, 20 Dec 2015 11:04:14 +0000 (+0100) Subject: airplane commit - implement pdnslog & loglevels that work (in contrast to lua 3.x... X-Git-Tag: dnsdist-1.0.0-alpha1~45^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=016889659c4f231be24d5fb7bb081a9ce92df4b8;p=pdns airplane commit - implement pdnslog & loglevels that work (in contrast to lua 3.x implementation) --- diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index fbfb77928..07657533b 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -207,17 +207,28 @@ RecursorLua4::RecursorLua4(const std::string& fname) }); d_lw->registerFunction("check",(bool (SuffixMatchNode::*)(const DNSName&) const) &SuffixMatchNode::check); - - vector> pd{ + + d_lw->writeFunction("pdnslog", [](const std::string& msg, int loglevel) { + theL() << (Logger::Urgency)loglevel << msg< > in_t; + vector > > pd{ {"PASS", (int)PolicyDecision::PASS}, {"DROP", (int)PolicyDecision::DROP}, {"TRUNCATE", (int)PolicyDecision::TRUNCATE} }; + pd.push_back({"loglevels", in_t{ + {"Critical", LOG_CRIT}, + {"Debug", LOG_DEBUG}, + {"Info", LOG_INFO}, + {"Notice", LOG_NOTICE}, + {"Warning", LOG_WARNING}, + {"Error", LOG_ERR} + }}); + for(const auto& n : QType::names) pd.push_back({n.first, n.second}); - - - d_lw->writeVariable("pdns", pd); + d_lw->writeVariable("pdns", pd); ifstream ifs(fname); if(!ifs) {