فهرست منبع

More log cleaning (to trace).

Steve Thielemann 3 سال پیش
والد
کامیت
a2b2d793ea
2فایلهای تغییر یافته به همراه25 افزوده شده و 24 حذف شده
  1. 23 21
      director.cpp
  2. 2 3
      session.cpp

+ 23 - 21
director.cpp

@@ -44,14 +44,17 @@ Director::Director() {
 
 Director::~Director() { BUGZ_LOG(warning) << "Director::~Director()"; }
 
-void Director::client_input(const std::string &input) {
-  // If we're already active, don't try to activate.
-
+void Director::client_input(const std::string &input) { 
   if (chain) {
+    BUGZ_LOG(trace) << chain->name << " CI: [" << input << "]";
     chain->client_input(input);
     return;
+  } else {
+    BUGZ_LOG(trace) << "CI: [" << input << "]";
   }
 
+  // If we're already active, don't try to activate.
+
   if (active) {
     if (input == "Q" || input == "q") proxy_deactivate();
     return;
@@ -75,9 +78,6 @@ void Director::client_input(const std::string &input) {
 
       to_client(std::string("\n\r") + c1() + "I'd choose " + c2() + "`T`" +
                 c1() + ", but that's how I was coded.\n\r");
-      //          "\n\r\x1b[1;36mI'd choose \x1b[1;37m`T`\x1b[1;36m, but "
-      //          "that's how I was coded.\n\r");
-
       to_client(current_raw_prompt);
       return;
     }
@@ -915,7 +915,7 @@ void Director::SL_cimline(const std::string &line) {
       galaxy.add_port(p);
     // else
     //  BUGZ_LOG(trace) << "portcim: " << p;
-    
+
   } else {
     // warpcim
     // BUGZ_LOG(fatal) << "warpcim: [" << line << "]";
@@ -947,7 +947,7 @@ void Director::SL_thiefline(const std::string &line) {
   // Are those the two ways to exit from this state?
 }
 void Director::SL_sectorline(const std::string &line) {
-  BUGZ_LOG(fatal) << "sectorline: [" << line << "]";
+  // BUGZ_LOG(fatal) << "sectorline: [" << line << "]";
   if (line.empty()) {
     SL_parser = nullptr;
   } else {
@@ -970,7 +970,7 @@ void Director::SL_sectorline(const std::string &line) {
     */
     if (in(line, "Sector  :")) {
       current_sector = stoi(line.substr(10));
-      BUGZ_LOG(warning) << "SECTOR: " << current_sector;
+      // BUGZ_LOG(trace) << "SECTOR: " << current_sector;
     }
     if (in(line, "Ports   :")) {
       std::string port_class;
@@ -978,7 +978,7 @@ void Director::SL_sectorline(const std::string &line) {
       if (pos != std::string::npos) {
         pos += 8;
         int class_ = stoi(line.substr(pos));
-        BUGZ_LOG(fatal) << "PORT: " << class_;
+        // BUGZ_LOG(trace) << "PORT: " << class_;
         galaxy.add_port(current_sector, class_);
       }
     }
@@ -996,14 +996,14 @@ void Director::SL_sectorline(const std::string &line) {
       for (auto const &w : warps) {
         sw.add(stoi(w));
       }
-      BUGZ_LOG(fatal) << "WARPS: " << sw;
+      // BUGZ_LOG(trace) << "WARPS: " << sw;
       galaxy.add_warp(sw);
     }
   }
 }
 
 void Director::SL_densityline(const std::string &line) {
-  BUGZ_LOG(trace) << "densityline: [" << line << "]";
+  // BUGZ_LOG(trace) << "densityline: [" << line << "]";
   if (line.empty()) {
     SL_parser = nullptr;
     return;
@@ -1195,7 +1195,7 @@ void Director::SL_infoline(const std::string &line) {
       if (galaxy.meta["info"].contains("Turns to Warp")) {
         // Why is this saying that this is a string?
         int warp_turns = sstoi(json_str(galaxy.meta["info"]["Turns to Warp"]));
-        BUGZ_LOG(fatal) << "Turns to Warp: " << warp_turns;
+        // BUGZ_LOG(trace) << "Turns to Warp: " << warp_turns;
         galaxy.meta["ship"]["warp_turns"] = warp_turns;
       }
 
@@ -1203,7 +1203,7 @@ void Director::SL_infoline(const std::string &line) {
         std::string scanner_text =
             galaxy.meta["info"]["LongRange Scan"].get<std::string>();
         char scanner = scanner_text[0];
-        BUGZ_LOG(fatal) << "Scanner: " << scanner;
+        // BUGZ_LOG(trace) << "Scanner: " << scanner;
         galaxy.meta["ship"]["scanner"] = scanner;
       }
 
@@ -1216,14 +1216,14 @@ void Director::SL_infoline(const std::string &line) {
         } else {
           int turns =
               stoi(text);  // galaxy.meta["info"]["Turns left"].as<int>();
-          BUGZ_LOG(fatal) << "Turns left: " << turns;
+          // BUGZ_LOG(trace) << "Turns left: " << turns;
           galaxy.meta["turns"] = turns;
         }
       }
 
       if (galaxy.meta["info"].contains("Current Sector")) {
         int sector = sstoi(json_str(galaxy.meta["info"]["Current Sector"]));
-        BUGZ_LOG(fatal) << "Sector: " << sector;
+        // BUGZ_LOG(trace) << "Sector: " << sector;
         // it should already be sector ...
         current_sector = sector;
       }
@@ -1233,7 +1233,7 @@ void Director::SL_infoline(const std::string &line) {
         replace(credit_text, ",", "");
         int credits = stoi(credit_text);
         galaxy.meta["credits"] = credits;
-        BUGZ_LOG(fatal) << "Credits: " << credits;
+        // BUGZ_LOG(trace) << "Credits: " << credits;
       }
     }
     return;
@@ -1248,7 +1248,7 @@ void Director::SL_infoline(const std::string &line) {
     trim(key);
     trim(value);
     galaxy.meta["info"][key] = value;
-    BUGZ_LOG(fatal) << "Info: " << key << " : " << value;
+    // BUGZ_LOG(trace) << "Info: " << key << " : " << value;
   }
   // [Corp           # 1, Galaxy Stomping, Inc.]
   if (startswith(line, "Corp  ")) {
@@ -1309,8 +1309,8 @@ void Director::SL_computer_portline(const std::string &line) {
     // update port
     auto port = galaxy.ports.find(computer_port_sector);
     if (port != galaxy.ports.end()) {
-      BUGZ_LOG(info) << "COM PORT " << computer_port_sector << " " << c << " "
-                     << amount << " " << percent;
+      BUGZ_LOG(trace) << "COM PORT " << computer_port_sector << " " << c << " "
+                      << amount << " " << percent;
       port->second.amount[pos] = amount;
       port->second.percent[pos] = percent;
     }
@@ -1354,8 +1354,10 @@ void Director::SL_planetline(const std::string &line) {
     work = work.substr(0, pos);
     trim(work);
     name = work;
-    BUGZ_LOG(warning) << (int)sector << " # " << number << " Class " << c
+    /*
+    BUGZ_LOG(trace) << (int)sector << " # " << number << " Class " << c
                       << " Level " << level << " name: [" << name << "]";
+    */
     planet p{sector, number, level, name, c};
     galaxy.planets[number] = p;
   }

+ 2 - 3
session.cpp

@@ -453,7 +453,6 @@ void Session::on_resolve(
 
 void Session::client_input(const std::string &input) {
   std::string temp = repr(input);
-  BUGZ_LOG(trace) << "CI: [" << temp << "]";
   director.client_input(input);
 }
 
@@ -472,7 +471,7 @@ void Session::client_read(void) {
 
             // parse authentication information
             parse_auth();
-            to_client(std::string(1, 0));
+            to_client(std::string(1, 0), false);
 
             to_client("Welcome, ");
             to_client(rlogin_name);
@@ -538,7 +537,7 @@ void Session::to_client(const std::string &message, bool log) {
 }
 
 void Session::to_server(const std::string &message) {
-  std::string empty;
+  static std::string empty;
   to_server(message, empty);
 }