From d18c48de7e4be85d761246d445d32585060ffe3c Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Sun, 26 Sep 2021 21:06:23 +0200 Subject: Added some more context to http failure logging --- zenhttp/httpsys.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'zenhttp/httpsys.cpp') diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index 28a9f7abf..9c747d17e 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -553,7 +553,10 @@ HttpMessageResponseRequest::IssueRequest(std::error_code& ErrorCode) CancelThreadpoolIo(Iocp); - ZEN_ERROR("failed to send HTTP response (error: '{}'), request URL: '{}'", GetWindowsErrorAsString(SendResult), HttpReq->pRawUrl); + ZEN_ERROR("failed to send HTTP response (error: '{}'), request URL: '{}', request id: {}", + GetWindowsErrorAsString(SendResult), + HttpReq->pRawUrl, + HttpReq->RequestId); ErrorCode = MakeWin32ErrorCode(SendResult); } -- cgit v1.2.3 From d84260d180be72b547d04351c91a02e7c75f2b51 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Sun, 26 Sep 2021 22:09:13 +0200 Subject: httpsys: Some logging improvements --- zenhttp/httpsys.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'zenhttp/httpsys.cpp') diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index 9c747d17e..2a50388e3 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -575,7 +575,10 @@ HttpMessageResponseRequest::IssueRequest(std::error_code& ErrorCode) \/ \/ \/ */ -HttpSysServer::HttpSysServer(unsigned int ThreadCount) : m_ThreadPool(ThreadCount) +HttpSysServer::HttpSysServer(unsigned int ThreadCount) +: m_Log(logging::Get("http")) +, m_RequestLog(logging::Get("http_requests")) +, m_ThreadPool(ThreadCount) { ULONG Result = HttpInitialize(HTTPAPI_VERSION_2, HTTP_INITIALIZE_SERVER, nullptr); @@ -671,6 +674,8 @@ HttpSysServer::Initialize(const wchar_t* UrlPath) else { m_IsOk = true; + + ZEN_INFO("Started http.sys server at '{}'", WideToUtf8(UrlPath)); } } @@ -950,6 +955,14 @@ HttpSysTransaction::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesTran return Status::kRequestPending; } + if (m_HttpServer.m_IsRequestLoggingEnabled) + { + if (m_HandlerRequest.has_value()) + { + m_HttpServer.m_RequestLog.info("{} {}", ToString(m_HandlerRequest->RequestVerb()), m_HandlerRequest->RelativeUri()); + } + } + // Transaction done, caller should clean up (delete) this instance return Status::kDone; } -- cgit v1.2.3 From dd9aec560688547dfd60090436d843c76450bd62 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 27 Sep 2021 11:43:40 +0200 Subject: GetWindowsErrorAsString() -> GetSystemErrorAsString() --- zenhttp/httpsys.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zenhttp/httpsys.cpp') diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index 2a50388e3..b08e39a8a 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -417,7 +417,7 @@ HttpMessageResponseRequest::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfB if (IoResult != NO_ERROR) { - ZEN_WARN("response aborted due to error: '{}'", GetWindowsErrorAsString(IoResult)); + ZEN_WARN("response aborted due to error: '{}'", GetSystemErrorAsString(IoResult)); // if one transmit failed there's really no need to go on return nullptr; @@ -554,7 +554,7 @@ HttpMessageResponseRequest::IssueRequest(std::error_code& ErrorCode) CancelThreadpoolIo(Iocp); ZEN_ERROR("failed to send HTTP response (error: '{}'), request URL: '{}', request id: {}", - GetWindowsErrorAsString(SendResult), + GetSystemErrorAsString(SendResult), HttpReq->pRawUrl, HttpReq->RequestId); -- cgit v1.2.3