From: Chris Hofstaedtler Date: Mon, 3 Sep 2018 09:39:59 +0000 (+0200) Subject: recursor: Allow pdnslog to Lua configuration files X-Git-Tag: rec-4.1.5~10^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6919%2Fhead;p=thirdparty%2Fpdns.git recursor: Allow pdnslog to Lua configuration files --- diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index e68836f5b0..d25f0e9878 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -96,6 +96,21 @@ void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) auto luaconfsLocal = g_luaconfs.getLocal(); + // pdnslog here is compatible with pdnslog in lua-base4.cc. + Lua.writeFunction("pdnslog", [](const std::string& msg, boost::optional loglevel) { L << (Logger::Urgency)loglevel.get_value_or(Logger::Warning) << msg<> pdns_table; + pdns_table["loglevels"] = std::unordered_map{ + {"Alert", LOG_ALERT}, + {"Critical", LOG_CRIT}, + {"Debug", LOG_DEBUG}, + {"Emergency", LOG_EMERG}, + {"Info", LOG_INFO}, + {"Notice", LOG_NOTICE}, + {"Warning", LOG_WARNING}, + {"Error", LOG_ERR} + }; + Lua.writeVariable("pdns", pdns_table); + Lua.writeFunction("clearSortlist", [&lci]() { lci.sortlist.clear(); }); /* we can get: "1.2.3.4"