Skip to content

Commit

Permalink
Fix some logging bugs and improve log levels (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaybd authored Jul 20, 2024
1 parent c921c07 commit 039fd3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/Rover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ void parseCommandLine(int argc, char** argv) {
{"LOG_ERROR", loguru::Verbosity_ERROR},
{"LOG_WARN", loguru::Verbosity_WARNING},
{"LOG_INFO", loguru::Verbosity_INFO},
{"LOG_DEBUG", 2},
{"LOG_TRACE", 1},
{"LOG_VERBOSE", 1},
{"LOG_TRACE", 2},
{"LOG_DEBUG", 3},
};

if (allowed.find(value) != allowed.end()) {
loguru::g_stderr_verbosity = allowed[value];
return value;
} else {
throw std::runtime_error("Invalid log level " + value);
}

throw std::runtime_error("Invalid log level " + value);
});

program.add_argument("-nc", "--no-colors")
Expand Down
6 changes: 3 additions & 3 deletions src/network/websocket/WebSocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void SingleClientWSServer::onOpen(connection_hdl hdl) {
ProtocolData& pd = this->getProtocol(path).value();
std::lock_guard lock(pd.mutex);
if (pd.client.has_value()) {
LOG_F(2, "Ping!");
LOG_F(3, "Ping!");
server.ping(pd.client.value(), path);
}
});
Expand Down Expand Up @@ -206,7 +206,7 @@ void SingleClientWSServer::onMessage(connection_hdl hdl, message_t message) {
// No need to lock this pd because we only access the protocol, which is constant
ProtocolData& pd = protocolDataOpt.value();
std::string jsonStr = message->get_payload();
LOG_F(1, "Message on %s: %s", path.c_str(), jsonStr.c_str());
LOG_F(2, "Message on %s: %s", path.c_str(), jsonStr.c_str());
json obj = json::parse(jsonStr);
pd.protocol->processMessage(obj);
} else {
Expand All @@ -215,7 +215,7 @@ void SingleClientWSServer::onMessage(connection_hdl hdl, message_t message) {
}

void SingleClientWSServer::onPong(connection_hdl hdl, const std::string& payload) {
LOG_F(2, "Pong from %s", payload.c_str());
LOG_F(3, "Pong from %s", payload.c_str());
auto conn = server.get_con_from_hdl(hdl);

auto protocolDataOpt = this->getProtocol(payload);
Expand Down

0 comments on commit 039fd3d

Please sign in to comment.