]> granicus.if.org Git - pdns/commitdiff
recursor: Allow pdnslog to Lua configuration files
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Mon, 3 Sep 2018 09:39:59 +0000 (11:39 +0200)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Mon, 3 Sep 2018 10:03:35 +0000 (12:03 +0200)
pdns/rec-lua-conf.cc

index e68836f5b0002ad787a0f30e0e272bcf19b5c72b..d25f0e9878943fca443716a953f5dddbfecf131f 100644 (file)
@@ -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<int> loglevel) { L << (Logger::Urgency)loglevel.get_value_or(Logger::Warning) << msg<<endl; });
+  std::unordered_map<string, std::unordered_map<string, int>> pdns_table;
+  pdns_table["loglevels"] = std::unordered_map<string, int>{
+    {"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"