From 003fc27e46953a70a10d40a9d94fe29732b99468 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Fri, 10 Aug 2018 18:26:23 +0200 Subject: [PATCH] Add pdnslog to Lua configuration scripts Gbp-Pq: Name 0001-Add-pdnslog-to-Lua-configuration-scripts.patch --- rec-lua-conf.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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" -- 2.30.2