Browse Source

[2216] added -d option to dump debug logs

not directly related, but would be useful for extending the benchmark
code and to check the server behavioer.
JINMEI Tatuya 12 years ago
parent
commit
eeeace345b
1 changed files with 18 additions and 13 deletions
  1. 18 13
      src/bin/auth/benchmarks/query_bench.cc

+ 18 - 13
src/bin/auth/benchmarks/query_bench.cc

@@ -14,13 +14,6 @@
 
 #include <config.h>
 
-#include <stdlib.h>
-
-#include <iostream>
-#include <vector>
-
-#include <boost/shared_ptr.hpp>
-
 #include <bench/benchmark.h>
 #include <bench/benchmark_util.h>
 
@@ -42,6 +35,13 @@
 #include <asiodns/asiodns.h>
 #include <asiolink/asiolink.h>
 
+#include <boost/shared_ptr.hpp>
+
+#include <stdlib.h>
+
+#include <iostream>
+#include <vector>
+
 using namespace std;
 using namespace isc;
 using namespace isc::data;
@@ -187,8 +187,9 @@ enum DataSrcType {
 void
 usage() {
     cerr <<
-        "Usage: query_bench [-n iterations] [-t datasrc_type] [-o origin] "
-        "datasrc_file query_datafile\n"
+        "Usage: query_bench [-d] [-n iterations] [-t datasrc_type] [-o origin]"
+        " datasrc_file query_datafile\n"
+        "  -d Enable debug logging to stdout\n"
         "  -n Number of iterations per test case (default: "
          << ITERATION_DEFAULT << ")\n"
         "  -t Type of data source: sqlite3|memory (default: sqlite3)\n"
@@ -208,7 +209,8 @@ main(int argc, char* argv[]) {
     int iteration = ITERATION_DEFAULT;
     const char* opt_datasrc_type = "sqlite3";
     const char* origin = NULL;
-    while ((ch = getopt(argc, argv, "n:t:o:")) != -1) {
+    bool debug_log = false;
+    while ((ch = getopt(argc, argv, "dn:t:o:")) != -1) {
         switch (ch) {
         case 'n':
             iteration = atoi(optarg);
@@ -219,6 +221,9 @@ main(int argc, char* argv[]) {
         case 'o':
             origin = optarg;
             break;
+        case 'd':
+            debug_log = true;
+            break;
         case '?':
         default:
             usage();
@@ -232,9 +237,9 @@ main(int argc, char* argv[]) {
     const char* const datasrc_file = argv[0];
     const char* const query_data_file = argv[1];
 
-    // We disable logging to avoid unwanted noise. (We may eventually want to
-    // make it more configurable)
-    initLogger("query-bench", isc::log::NONE);
+    // By default disable logging to avoid unwanted noise.
+    initLogger("query-bench", debug_log ? isc::log::DEBUG : isc::log::NONE,
+               isc::log::MAX_DEBUG_LEVEL, NULL);
 
     DataSrcType datasrc_type = SQLITE3;
     if (strcmp(opt_datasrc_type, "sqlite3") == 0) {