]> granicus.if.org Git - pdns/commitdiff
make second argument to pdnslog optional
authorThiago Farina <tfarina@chromium.org>
Thu, 3 Mar 2016 13:32:59 +0000 (10:32 -0300)
committerThiago Farina <tfarina@chromium.org>
Fri, 4 Mar 2016 18:39:25 +0000 (15:39 -0300)
This patch makes the |loglevel| parameter for pdnslog in Lua, optional.
If not specified the default log level will be Warning.

Fixes #3487

pdns/lua-recursor4.cc

index 1543a7bdae4ad7005b184c9e0b4fbe9545288892..df22aca8f0ec7fb08ca847c9307e0fb24ceb25b4 100644 (file)
@@ -339,8 +339,8 @@ RecursorLua4::RecursorLua4(const std::string& fname)
   d_lw->registerFunction("check",(bool (SuffixMatchNode::*)(const DNSName&) const) &SuffixMatchNode::check);
 
 
-  d_lw->writeFunction("pdnslog", [](const std::string& msg, int loglevel) {
-      theL() << (Logger::Urgency)loglevel << msg<<endl;
+  d_lw->writeFunction("pdnslog", [](const std::string& msg, boost::optional<int> loglevel) {
+      theL() << loglevel.get_value_or(Logger::Warning) << msg<<endl;
     });
   typedef vector<pair<string, int> > in_t;
   vector<pair<string, boost::variant<int, in_t, struct timeval* > > >  pd{
@@ -358,7 +358,7 @@ RecursorLua4::RecursorLua4(const std::string& fname)
        {"Warning", LOG_WARNING},
        {"Error", LOG_ERR}
          }});
-  
+
   for(const auto& n : QType::names)
     pd.push_back({n.first, n.second});
   pd.push_back({"now", &g_now});