Skip to content

Commit a2fe52d

Browse files
committed
fix(log): remove all the log output
1 parent c1126e8 commit a2fe52d

File tree

8 files changed

+34
-34
lines changed

8 files changed

+34
-34
lines changed

src/core/common/config.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ void Config::LoadConfigFile(const std::string& file_path) {
1717
tinyxml2::XMLDocument doc;
1818
tinyxml2::XMLError error = doc.LoadFile(file_path.c_str());
1919
if (error != tinyxml2::XML_SUCCESS) {
20-
LOG_ERROR("Error: " + std::string(doc.ErrorStr()));
20+
// LOG_ERROR("Error: " + std::string(doc.ErrorStr()));
2121
return;
2222
}
2323

2424
tinyxml2::XMLElement* root = doc.FirstChildElement("root");
2525
if (!root) {
26-
LOG_ERROR("No <root>.\n");
26+
// LOG_ERROR("No <root>.\n");
2727
return;
2828
}
2929

src/core/common/logger.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class Logger {
3535

3636
// 定义宏,自动填入文件名和行号
3737
// 使用spdlog的格式化日志宏
38-
#define LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__)
39-
#define LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__)
40-
#define LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__)
41-
#define LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__)
38+
// #define LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__)
39+
// #define LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__)
40+
// #define LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__)
41+
// #define LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__)
4242

4343
#endif // PHOTONRPC_LOGGER_H

src/core/net/acceptor.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@ void Acceptor::StartListen() {
2424

2525
this->listenfd_ = socket(PF_INET, SOCK_STREAM, 0);
2626
if (listenfd_ < 0) {
27-
LOG_ERROR("create listen_fd failure");
27+
// LOG_ERROR("create listen_fd failure");
2828
return;
2929
}
3030

3131
// Enable the bind function to reuse the same port.
3232
// In some case, the socket haven't been released by the Linux OS, but the server run again.
3333
int opt = 1;
3434
if (setsockopt(listenfd_, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
35-
LOG_ERROR("setsockopt failure");
35+
// LOG_ERROR("setsockopt failure");
3636
}
3737

3838
int ret = bind(listenfd_, (struct sockaddr*)&address, sizeof(address));
3939
if (ret < 0) {
40-
LOG_ERROR("bind listen_fd failure, errno = " +
41-
std::string(strerror(errno)));
40+
// LOG_ERROR("bind listen_fd failure, errno = " +
41+
// std::string(strerror(errno)));
4242
exit(1);
4343
}
4444

4545
ret = listen(listenfd_, MAX_LISTEN);
4646
if (ret < 0) {
47-
LOG_ERROR("listen failure");
47+
// LOG_ERROR("listen failure");
4848
return;
4949
}
5050

51-
LOG_INFO("Acceptor start listening on {}:{}", ip, port);
51+
// LOG_INFO("Acceptor start listening on {}:{}", ip, port);
5252

5353
listen_channel = Channel(listenfd_, true, false);
5454
listen_channel.set_handle_read([this] {
@@ -57,13 +57,13 @@ void Acceptor::StartListen() {
5757
int connfd =
5858
accept(listenfd_, (struct sockaddr*)&client_addr, &client_addr_len);
5959
if (connfd < 0) {
60-
LOG_ERROR("accept failure");
60+
// LOG_ERROR("accept failure");
6161
return;
6262
}
6363

64-
LOG_INFO("Acceptor accepted new connection from {}:{}, fd: {}",
65-
inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port),
66-
connfd);
64+
// LOG_INFO("Acceptor accepted new connection from {}:{}, fd: {}",
65+
// inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port),
66+
// connfd);
6767
this->new_connection_callback_(connfd);
6868
});
6969

src/core/net/event_loop.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ EventLoop::EventLoop() : stopped_(false) {
2222
wakeup_channel->set_handle_read([this] {
2323
uint64_t one;
2424
int ret = read(wakeup_fd_, &one, sizeof(one));
25-
LOG_INFO("Signal: Stoping Loop");
25+
// LOG_INFO("Signal: Stoping Loop");
2626
stopped_ = true;
2727
});
2828

@@ -34,7 +34,7 @@ EventLoop::EventLoop() : stopped_(false) {
3434
}
3535

3636
void EventLoop::Loop() {
37-
LOG_INFO("EventLoop start looping");
37+
// LOG_INFO("EventLoop start looping");
3838
while (!stopped_) {
3939
int ret = poller_.poll(-1);
4040
if (ret < 0) {
@@ -56,7 +56,7 @@ void EventLoop::Loop() {
5656
}
5757
}
5858
}
59-
LOG_INFO("EventLoop finish looping");
59+
// LOG_INFO("EventLoop finish looping");
6060
}
6161

6262
void EventLoop::AddChannel(Channel* channel) {

src/core/net/poller.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ int Poller::poll(int timeout) {
1111
timeout);
1212
if (ret < 0) {
1313
if (errno == EINTR) {
14-
LOG_DEBUG("poll error: EINTR, continue");
14+
// LOG_DEBUG("poll error: EINTR, continue");
1515
return 0;
1616
}
17-
LOG_ERROR("epoll failure");
17+
// LOG_ERROR("epoll failure");
1818
return -1;
1919
}
2020
return ret;

src/core/net/tcp_connection.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void TcpConnection::HandleRead() {
3939
decoded_data.clear();
4040
}
4141
} else {
42-
LOG_INFO("TcpConnection(fd:{}) closed",
43-
static_cast<int>(channel_.event()->data.fd));
42+
// LOG_INFO("TcpConnection(fd:{}) closed",
43+
// static_cast<int>(channel_.event()->data.fd));
4444
close(channel_.event()->data.fd);
4545
}
4646
}

src/core/net/tcp_server.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
void TcpServer::SetUpTcpServer(
66
std::function<void(std::string&, std::string&)> service) {
77
acceptor_.set_start_listen_callback([this](Channel* channel) {
8-
LOG_DEBUG("Acceptor called listen_callback");
8+
// LOG_DEBUG("Acceptor called listen_callback");
99
event_loop_.AddChannel(channel);
1010
});
1111

@@ -20,7 +20,7 @@ void TcpServer::SetUpTcpServer(
2020
this->event_loop_.RemoveChannel(channel);
2121
this->fd_connection_map_.erase(channel->event()->data.fd);
2222
});
23-
LOG_INFO("TcpServer created new TcpConnection for fd: {}", connect_fd);
23+
// LOG_INFO("TcpServer created new TcpConnection for fd: {}", connect_fd);
2424
});
2525

2626
acceptor_.StartListen();

src/core/rpc/rpc_server.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RpcServer::RpcServer() {
1111
}
1212

1313
void RpcServer::StartServer() {
14-
LOG_INFO("RpcServer started");
14+
// LOG_INFO("RpcServer started");
1515
tcp_server_.RunLoop();
1616
}
1717

@@ -23,7 +23,7 @@ void RpcServer::HandleRequest(std::string& request, std::string& response) {
2323
rpc::RpcMessage request_message;
2424
request_message.ParseFromString(request);
2525

26-
LOG_DEBUG("Received request: \n" + request_message.DebugString());
26+
// LOG_DEBUG("Received request: \n" + request_message.DebugString());
2727

2828
if (!CheckRequest(request_message)) {
2929
rpc::RpcMessage response_message;
@@ -52,27 +52,27 @@ void RpcServer::HandleRequest(std::string& request, std::string& response) {
5252
response_message.set_response(method_response->SerializeAsString());
5353
response_message.SerializeToString(&response);
5454

55-
LOG_DEBUG("Send response: \n" + response_message.DebugString());
55+
// LOG_DEBUG("Send response: \n" + response_message.DebugString());
5656
}
5757

5858
bool RpcServer::CheckRequest(rpc::RpcMessage request) {
5959
if (request.type() != rpc::RPC_TYPE_REQUEST) {
60-
LOG_ERROR("Invalid request type: " + std::to_string(request.type()));
60+
// LOG_ERROR("Invalid request type: " + std::to_string(request.type()));
6161
return false;
6262
}
6363

6464
if (request.method_name().empty()) {
65-
LOG_ERROR("Empty method name");
65+
// LOG_ERROR("Empty method name");
6666
return false;
6767
}
6868

6969
if (request.service_name().empty()) {
70-
LOG_ERROR("Empty service name");
70+
// LOG_ERROR("Empty service name");
7171
return false;
7272
}
7373

7474
if (service_map_.find(request.service_name()) == service_map_.end()) {
75-
LOG_ERROR("Service not found: " + request.service_name());
75+
// LOG_ERROR("Service not found: " + request.service_name());
7676
return false;
7777
}
7878
auto service = service_map_.find(request.service_name())->second;
@@ -84,12 +84,12 @@ bool RpcServer::CheckRequest(rpc::RpcMessage request) {
8484
auto service_desc = service->GetDescriptor();
8585
auto method_desc = service_desc->FindMethodByName(request.method_name());
8686
if (method_desc == nullptr) {
87-
LOG_ERROR("Method not found: " + request.method_name());
87+
// LOG_ERROR("Method not found: " + request.method_name());
8888
return false;
8989
}
9090

9191
if (request.request().empty()) {
92-
LOG_ERROR("Empty request");
92+
// LOG_ERROR("Empty request");
9393
return false;
9494
}
9595

0 commit comments

Comments
 (0)