diff options
author | Marcin Siodelski <marcin@isc.org> | 2018-05-29 16:08:03 +0200 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2018-05-29 16:08:03 +0200 |
commit | 27cf2123e5710c9fb603c1f58e870ecf8a8c2feb (patch) | |
tree | 892f03bc963d2dc93b92c11c8a286617d2a16f10 /src/lib/http/connection.cc | |
parent | [master] Added path to OpenSSL from homebrew (diff) | |
download | kea-27cf2123e5710c9fb603c1f58e870ecf8a8c2feb.tar.xz kea-27cf2123e5710c9fb603c1f58e870ecf8a8c2feb.zip |
[5205] Improved HTTP server side logging.
Diffstat (limited to 'src/lib/http/connection.cc')
-rw-r--r-- | src/lib/http/connection.cc | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/lib/http/connection.cc b/src/lib/http/connection.cc index c6f3f36caa..11a272a03a 100644 --- a/src/lib/http/connection.cc +++ b/src/lib/http/connection.cc @@ -13,6 +13,15 @@ using namespace isc::asiolink; +namespace { + +/// @brief Maximum size of the HTTP message that can be logged. +/// +/// The part of the HTTP message beyond this value is truncated. +constexpr size_t MAX_LOGGED_MESSAGE_SIZE = 1024; + +} + namespace isc { namespace http { @@ -203,12 +212,28 @@ HttpConnection::socketReadCallback(boost::system::error_code ec, size_t length) doRead(); } else { - LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_DETAIL, - HTTP_REQUEST_RECEIVED) - .arg(getRemoteEndpointAddressAsText()); try { request_->finalize(); - } catch (...) { + + LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC, + HTTP_REQUEST_RECEIVED) + .arg(getRemoteEndpointAddressAsText()); + + LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC_DATA, + HTTP_REQUEST_DETAILS) + .arg(getRemoteEndpointAddressAsText()) + .arg(parser_->getBufferAsString(MAX_LOGGED_MESSAGE_SIZE)); + + } catch (const std::exception& ex) { + LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC, + HTTP_BAD_REQUEST_RECEIVED) + .arg(getRemoteEndpointAddressAsText()) + .arg(ex.what()); + + LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC_DATA, + HTTP_BAD_REQUEST_DETAILS) + .arg(getRemoteEndpointAddressAsText()) + .arg(parser_->getBufferAsString(MAX_LOGGED_MESSAGE_SIZE)); } HttpResponsePtr response = response_creator_->createHttpResponse(request_); @@ -216,6 +241,13 @@ HttpConnection::socketReadCallback(boost::system::error_code ec, size_t length) HTTP_RESPONSE_SEND) .arg(response->toBriefString()) .arg(getRemoteEndpointAddressAsText()); + + LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_DETAIL_DATA, + HTTP_RESPONSE_DETAILS) + .arg(getRemoteEndpointAddressAsText()) + .arg(HttpMessageParserBase::logFormatHttpMessage(response->toString(), + MAX_LOGGED_MESSAGE_SIZE)); + asyncSendResponse(response); } } |