From 5dc3aebc5945b04290de90b5df97775dc70ac086 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Mon, 3 Sep 2018 11:39:59 +0200 Subject: [PATCH] recursor: Allow pdnslog to Lua configuration files --- pdns/rec-lua-conf.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index e68836f5b..d25f0e987 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" -- 2.40.0