]> granicus.if.org Git - pdns/commitdiff
airplane commit - implement pdnslog & loglevels that work (in contrast to lua 3.x...
authorbert hubert <bert.hubert@netherlabs.nl>
Sun, 20 Dec 2015 11:04:14 +0000 (12:04 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Sun, 20 Dec 2015 11:05:07 +0000 (12:05 +0100)
pdns/lua-recursor4.cc

index fbfb77928edf046e6edd41ff0c269014c1c02848..07657533b10ca6d5271bae4c5015eca688946a5c 100644 (file)
@@ -207,17 +207,28 @@ RecursorLua4::RecursorLua4(const std::string& fname)
                                                                                   });
   d_lw->registerFunction("check",(bool (SuffixMatchNode::*)(const DNSName&) const) &SuffixMatchNode::check);
 
-  
-  vector<pair<string,int>> pd{
+
+  d_lw->writeFunction("pdnslog", [](const std::string& msg, int loglevel) {
+      theL() << (Logger::Urgency)loglevel << msg<<endl;
+    });
+  typedef vector<pair<string, int> > in_t;
+  vector<pair<string, boost::variant<int, in_t > > >  pd{
     {"PASS", (int)PolicyDecision::PASS}, {"DROP",  (int)PolicyDecision::DROP},
     {"TRUNCATE", (int)PolicyDecision::TRUNCATE}
   };
 
+  pd.push_back({"loglevels", in_t{
+       {"Critical", LOG_CRIT},
+       {"Debug", LOG_DEBUG},
+       {"Info", LOG_INFO},
+       {"Notice", LOG_NOTICE},
+       {"Warning", LOG_WARNING},
+       {"Error", LOG_ERR}
+         }});
+  
   for(const auto& n : QType::names)
     pd.push_back({n.first, n.second});
-  
-
-  d_lw->writeVariable("pdns", pd);            
+  d_lw->writeVariable("pdns", pd);
   
   ifstream ifs(fname);
   if(!ifs) {