Skip to content

Commit 3cb7c16

Browse files
authored
optimize some log level and msg desc (#721)
1 parent ba162bd commit 3cb7c16

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

event/hevent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static void __write_timeout_cb(htimer_t* timer) {
597597
if (io->io_type & HIO_TYPE_SOCKET) {
598598
char localaddrstr[SOCKADDR_STRLEN] = {0};
599599
char peeraddrstr[SOCKADDR_STRLEN] = {0};
600-
hlogw("write timeout [%s] <=> [%s]",
600+
hlogi("write timeout [%s] <=> [%s]",
601601
SOCKADDR_STR(io->localaddr, localaddrstr),
602602
SOCKADDR_STR(io->peeraddr, peeraddrstr));
603603
}

event/nio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void ssl_server_handshake(hio_t* io) {
8080
}
8181
}
8282
else {
83-
hloge("ssl handshake failed: %d", ret);
83+
hloge("ssl server handshake failed: %d", ret);
8484
io->error = ERR_SSL_HANDSHAKE;
8585
hio_close(io);
8686
}
@@ -101,7 +101,7 @@ static void ssl_client_handshake(hio_t* io) {
101101
}
102102
}
103103
else {
104-
hloge("ssl handshake failed: %d", ret);
104+
hloge("ssl client handshake failed: %d", ret);
105105
io->error = ERR_SSL_HANDSHAKE;
106106
hio_close(io);
107107
}

http/HttpMessage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool HttpCookie::parse(const std::string& str) {
9292
httponly = true;
9393
}
9494
else {
95-
hlogw("Unrecognized key '%s'", key.c_str());
95+
hlogi("Cookie Unrecognized key '%s'", key.c_str());
9696
}
9797
}
9898

http/HttpParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "Http1Parser.h"
44
#include "Http2Parser.h"
5+
#include "hlog.h"
56

67
HttpParser* HttpParser::New(http_session_type type, http_version version) {
78
HttpParser* hp = NULL;
@@ -12,7 +13,7 @@ HttpParser* HttpParser::New(http_session_type type, http_version version) {
1213
#ifdef WITH_NGHTTP2
1314
hp = new Http2Parser(type);
1415
#else
15-
fprintf(stderr, "Please recompile WITH_NGHTTP2!\n");
16+
hlogi("Please recompile WITH_NGHTTP2!\n");
1617
#endif
1718
}
1819

http/server/HttpHandler.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ int HttpHandler::sendFile() {
895895
int readbytes = MIN(file->buf.len, resp->content_length);
896896
size_t nread = file->read(file->buf.base, readbytes);
897897
if (nread <= 0) {
898-
hloge("read file error!");
898+
hloge("read file: %s error!", file->filepath);
899899
error = ERR_READ_FILE;
900900
writer->close(true);
901901
return nread;
@@ -967,7 +967,7 @@ int HttpHandler::upgradeWebSocket() {
967967
if (iter_protocol != req->headers.end()) {
968968
hv::StringList subprotocols = hv::split(iter_protocol->second, ',');
969969
if (subprotocols.size() > 0) {
970-
hlogw("%s: %s => just select first protocol %s", SEC_WEBSOCKET_PROTOCOL, iter_protocol->second.c_str(), subprotocols[0].c_str());
970+
hlogw("[%s:%d] %s: %s => just select first protocol %s", ip, port, SEC_WEBSOCKET_PROTOCOL, iter_protocol->second.c_str(), subprotocols[0].c_str());
971971
resp->headers[SEC_WEBSOCKET_PROTOCOL] = subprotocols[0];
972972
}
973973
}
@@ -997,7 +997,7 @@ int HttpHandler::upgradeHTTP2() {
997997
SendHttpResponse();
998998

999999
if (!SwitchHTTP2()) {
1000-
hloge("[%s:%d] unsupported HTTP2", ip, port);
1000+
hlogw("[%s:%d] unsupported HTTP2", ip, port);
10011001
return SetError(ERR_INVALID_PROTOCOL);
10021002
}
10031003

@@ -1024,7 +1024,7 @@ int HttpHandler::handleForwardProxy() {
10241024
if (service && service->enable_forward_proxy) {
10251025
return connectProxy(req->url);
10261026
} else {
1027-
hlogw("Forbidden to forward proxy %s", req->url.c_str());
1027+
hlogw("[%s:%d] Forbidden to forward proxy %s", ip, port, req->url.c_str());
10281028
SetError(HTTP_STATUS_FORBIDDEN, HTTP_STATUS_FORBIDDEN);
10291029
}
10301030
return 0;
@@ -1057,7 +1057,7 @@ int HttpHandler::connectProxy(const std::string& strUrl) {
10571057
}
10581058

10591059
if (forward_proxy && !service->IsTrustProxy(url.host.c_str())) {
1060-
hlogw("Forbidden to proxy %s", url.host.c_str());
1060+
hlogw("[%s:%d] Forbidden to proxy %s", ip, port, url.host.c_str());
10611061
SetError(HTTP_STATUS_FORBIDDEN, HTTP_STATUS_FORBIDDEN);
10621062
return 0;
10631063
}

ssl/openssl.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "hssl.h"
2-
2+
#include "hlog.h"
33
#ifdef WITH_OPENSSL
44

55
#include "openssl/ssl.h"
@@ -117,6 +117,12 @@ int hssl_accept(hssl_t ssl) {
117117
else if (err == SSL_ERROR_WANT_WRITE) {
118118
return HSSL_WANT_WRITE;
119119
}
120+
else if (err == SSL_ERROR_SYSCALL) {
121+
hloge("SSL_accept errno:%d,error:%s", errno, strerror(errno));
122+
}
123+
else {
124+
hloge("SSL_accept: %s", ERR_error_string(ERR_get_error(), NULL));
125+
}
120126
return err;
121127
}
122128

@@ -131,6 +137,12 @@ int hssl_connect(hssl_t ssl) {
131137
else if (err == SSL_ERROR_WANT_WRITE) {
132138
return HSSL_WANT_WRITE;
133139
}
140+
else if (err == SSL_ERROR_SYSCALL) {
141+
hloge("SSL_connect errno:%d,error:%s", errno, strerror(errno));
142+
}
143+
else {
144+
hloge("SSL_connect: %s", ERR_error_string(ERR_get_error(), NULL));
145+
}
134146
return err;
135147
}
136148

0 commit comments

Comments
 (0)