]> granicus.if.org Git - pdns/commitdiff
implement logging from lua
authorbert hubert <bert.hubert@netherlabs.nl>
Mon, 9 Mar 2015 20:45:36 +0000 (21:45 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Mon, 9 Mar 2015 20:45:36 +0000 (21:45 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdist.cc
pdns/dnsdistconf.lua

index fb351f8141d5236c428cdb0190bc6bbe75eecef1..5ef4048e73ad74b4502afbec609da758788d562e 100644 (file)
@@ -325,6 +325,17 @@ vector<std::function<void(void)>> setupLua(bool client)
   g_lua.registerMember("weight", &DownstreamState::weight);
   g_lua.registerMember("order", &DownstreamState::order);
   
+  g_lua.writeFunction("infolog", [](const string& arg) {
+      infolog("%s", arg);
+    });
+  g_lua.writeFunction("errlog", [](const string& arg) {
+      errlog("%s", arg);
+    });
+  g_lua.writeFunction("warnlog", [](const string& arg) {
+      warnlog("%s", arg);
+    });
+
+
   g_lua.writeFunction("show", [](const string& arg) {
       g_outputBuffer+=arg;
       g_outputBuffer+="\n";
index a2a80e2a23a54b1c11b8a3ba73c26451dd9cb2c2..40a9008deb8e43247e560201fbc9634fb407f1a0 100644 (file)
@@ -44,7 +44,6 @@
    We neglect to do recvfromto() on 0.0.0.0
    Receiver is currently singlethreaded (not that bad actually)
    lack of help()
-   we offer no way to log from Lua
 */
 
 namespace po = boost::program_options;
index d77986e2f5b447f0989e79b0c530da3572a5a2b8..995efdd149b9ece2c4d2f58e069a4a4ed8d64ecb 100644 (file)
@@ -2,6 +2,8 @@ controlSocket("0.0.0.0")
 addLocal("0.0.0.0:5200")
 setKey("MXNeLFWHUe4363BBKrY06cAsH8NWNb+Se2eXU5+Bb74=")
 
+warnlog(string.format("Script starting %s", "up!"))
+
 -- define the good servers
 newServer("8.8.8.8", 2)  -- 2 qps
 newServer("8.8.4.4", 2)