From: Chris Hofstaedtler Date: Fri, 10 Aug 2018 16:26:23 +0000 (+0200) Subject: Add pdnslog to Lua configuration scripts X-Git-Tag: archive/raspbian/4.1.11-1+rpi1~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=003fc27e46953a70a10d40a9d94fe29732b99468;p=pdns-recursor.git Add pdnslog to Lua configuration scripts Gbp-Pq: Name 0001-Add-pdnslog-to-Lua-configuration-scripts.patch --- diff --git a/rec-lua-conf.cc b/rec-lua-conf.cc index e68836f..d25f0e9 100644 --- a/rec-lua-conf.cc +++ b/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"