server:日志打印等级。

This commit is contained in:
taynpg 2025-05-11 22:43:33 +08:00
parent 43aedf6f08
commit abca5ffa4f
2 changed files with 8 additions and 5 deletions

View File

@ -104,11 +104,11 @@ void RelayServer::thClientThread(const std::shared_ptr<wxSocketBase>& wxSock, co
wxSock->Read(client->buf.data(), GBUFFER_SIZE); wxSock->Read(client->buf.data(), GBUFFER_SIZE);
auto br = wxSock->LastCount(); auto br = wxSock->LastCount();
if (br == 0) { if (br == 0) {
wxLogMessage(wxT("Client disconnected: %s"), id); wxLogMessage(wxT("client disconnected: %s"), id);
ClearClient(id); ClearClient(id);
break; break;
} else if (wxSock->Error()) { } else if (wxSock->Error()) {
wxLogMessage(wxT("%s Client error: %s"), id, wxSock->LastError()); wxLogError(wxT("%s client error: %s"), id, wxSock->LastError());
ClearClient(id); ClearClient(id);
break; break;
} }
@ -164,7 +164,7 @@ void RelayServer::ReplyRequest(const sockPtr& wxSock, FrameBuffer* frame)
switch (frame->dataType) { switch (frame->dataType) {
case FBT_SER_MSG_ASKCLIENTS: { case FBT_SER_MSG_ASKCLIENTS: {
RpyOnline(wxSock, frame); RpyOnline(wxSock, frame);
wxLogDebug(wxT("Reply clients to %s clients list."), frame->fid); wxLogMessage(wxT("Reply clients to %s clients list."), frame->fid);
break; break;
} }
default: default:
@ -176,11 +176,11 @@ void RelayServer::ClearClient(const wxString& id)
{ {
std::unique_lock<std::shared_mutex> lock(clientsMutex_); std::unique_lock<std::shared_mutex> lock(clientsMutex_);
if (clients_.find(id) != clients_.end()) { if (clients_.find(id) != clients_.end()) {
wxLogDebug(wxT("client cleared: %s"), id); wxLogWarning(wxT("client cleared: %s"), id);
clients_.erase(id); clients_.erase(id);
} }
if (threads_.find(id) != threads_.end()) { if (threads_.find(id) != threads_.end()) {
wxLogDebug(wxT("client thread detached: %s"), id); wxLogWarning(wxT("client thread detached: %s"), id);
threads_[id].detach(); threads_[id].detach();
threads_.erase(id); threads_.erase(id);
} }

View File

@ -11,7 +11,10 @@ int main(int argc, char** argv)
return -1; return -1;
} }
auto* dl = wxLog::GetActiveTarget(); auto* dl = wxLog::GetActiveTarget();
dl->EnableLogging(true);
dl->SetFormatter(new MLogFormatter()); dl->SetFormatter(new MLogFormatter());
wxLog::SetLogLevel(wxLOG_Trace);
auto server_ = std::make_unique<RelayServer>(); auto server_ = std::make_unique<RelayServer>();
if (server_->Init("127.0.0.1", 8080)) { if (server_->Init("127.0.0.1", 8080)) {
server_->Run(); server_->Run();