Skip to content

Commit 5f3ab3c

Browse files
committed
optimize some log level and msg desc
1 parent 1e3dd55 commit 5f3ab3c

6 files changed

Lines changed: 24 additions & 11 deletions

File tree

event/hevent.c

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

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
@@ -881,7 +881,7 @@ int HttpHandler::sendFile() {
881881
int readbytes = MIN(file->buf.len, resp->content_length);
882882
size_t nread = file->read(file->buf.base, readbytes);
883883
if (nread <= 0) {
884-
hloge("read file error!");
884+
hloge("read file: %s error!", file->filepath);
885885
error = ERR_READ_FILE;
886886
writer->close(true);
887887
return nread;
@@ -953,7 +953,7 @@ int HttpHandler::upgradeWebSocket() {
953953
if (iter_protocol != req->headers.end()) {
954954
hv::StringList subprotocols = hv::split(iter_protocol->second, ',');
955955
if (subprotocols.size() > 0) {
956-
hlogw("%s: %s => just select first protocol %s", SEC_WEBSOCKET_PROTOCOL, iter_protocol->second.c_str(), subprotocols[0].c_str());
956+
hlogw("[%s:%d] %s: %s => just select first protocol %s", ip, port, SEC_WEBSOCKET_PROTOCOL, iter_protocol->second.c_str(), subprotocols[0].c_str());
957957
resp->headers[SEC_WEBSOCKET_PROTOCOL] = subprotocols[0];
958958
}
959959
}
@@ -983,7 +983,7 @@ int HttpHandler::upgradeHTTP2() {
983983
SendHttpResponse();
984984

985985
if (!SwitchHTTP2()) {
986-
hloge("[%s:%d] unsupported HTTP2", ip, port);
986+
hlogw("[%s:%d] unsupported HTTP2", ip, port);
987987
return SetError(ERR_INVALID_PROTOCOL);
988988
}
989989

@@ -1010,7 +1010,7 @@ int HttpHandler::handleForwardProxy() {
10101010
if (service && service->enable_forward_proxy) {
10111011
return connectProxy(req->url);
10121012
} else {
1013-
hlogw("Forbidden to forward proxy %s", req->url.c_str());
1013+
hlogw("[%s:%d] Forbidden to forward proxy %s", ip, port, req->url.c_str());
10141014
SetError(HTTP_STATUS_FORBIDDEN, HTTP_STATUS_FORBIDDEN);
10151015
}
10161016
return 0;
@@ -1043,7 +1043,7 @@ int HttpHandler::connectProxy(const std::string& strUrl) {
10431043
}
10441044

10451045
if (forward_proxy && !service->IsTrustProxy(url.host.c_str())) {
1046-
hlogw("Forbidden to proxy %s", url.host.c_str());
1046+
hlogw("[%s:%d] Forbidden to proxy %s", ip, port, url.host.c_str());
10471047
SetError(HTTP_STATUS_FORBIDDEN, HTTP_STATUS_FORBIDDEN);
10481048
return 0;
10491049
}

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)