From 08572a9376e6f41109e233cb45d7e491ad1ebf07 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 4 Dec 2020 14:16:19 +0000 Subject: Improve HTTP logging. --- src/modules/m_httpd.cpp | 6 +++++- src/modules/m_httpd_config.cpp | 2 +- src/modules/m_httpd_stats.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index b4e221e62..efed34799 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -266,12 +266,16 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru void SendHTTPError(unsigned int response, const char* errstr = NULL) { + if (!errstr) + errstr = http_status_str((http_status)response); + + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Sending HTTP error %u: %s", response, errstr); static HTTPHeaders empty; std::string data = InspIRCd::Format( "" "

Error %u

%s


" "Powered by InspIRCd", - response, errstr ? errstr : http_status_str((http_status)response)); + response, errstr); Page(data, response, &empty); } diff --git a/src/modules/m_httpd_config.cpp b/src/modules/m_httpd_config.cpp index fe1427772..bc669dae3 100644 --- a/src/modules/m_httpd_config.cpp +++ b/src/modules/m_httpd_config.cpp @@ -42,7 +42,7 @@ class ModuleHttpConfig : public Module, public HTTPRequestEventListener if ((request.GetPath() != "/config") && (request.GetPath() != "/config/")) return MOD_RES_PASSTHRU; - ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling request for the HTTP /config route"); + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling HTTP request for %s", request.GetPath().c_str()); std::stringstream buffer; ConfigDataHash& config = ServerInstance->Config->config_data; diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index b40c44d12..0b674cf64 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -431,7 +431,7 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener if (path[path.size() - 1] == '/') path.erase(path.size() - 1, 1); - ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling httpd event"); + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling HTTP request for %s", http->GetPath().c_str()); bool found = true; std::stringstream data; -- cgit v1.2.3