From 58edbe86be21cbead56f08b2a068bd7cbb82e2a7 Mon Sep 17 00:00:00 2001 From: whaffman Date: Sun, 21 Sep 2025 21:25:46 +0200 Subject: [PATCH] Refactor logging levels: change LOG_INFO to LOG_DEBUG in Client destructor and LOG_INFO to LOG_TRACE in ServerConfig for improved log granularity --- webserv/client/Client.cpp | 3 ++- webserv/config/ServerConfig.cpp | 17 ++++++++--------- webserv/main.cpp | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/webserv/client/Client.cpp b/webserv/client/Client.cpp index 546e993..5b7e9ca 100644 --- a/webserv/client/Client.cpp +++ b/webserv/client/Client.cpp @@ -1,3 +1,4 @@ +#include "webserv/log/LogLevel.hpp" #include "webserv/socket/Socket.hpp" #include @@ -12,7 +13,7 @@ Client::Client(std::unique_ptr socket, Server &server, const ServerConfi Client::~Client() { - LOG_INFO("Client destructor called for fd: " + std::to_string(client_socket_->getFd())); + LOG_DEBUG("Client destructor called for fd: " + std::to_string(client_socket_->getFd())); server_.removeFromEpoll(*client_socket_); }; diff --git a/webserv/config/ServerConfig.cpp b/webserv/config/ServerConfig.cpp index 4e874de..8fc3979 100644 --- a/webserv/config/ServerConfig.cpp +++ b/webserv/config/ServerConfig.cpp @@ -43,7 +43,7 @@ void ServerConfig::parseServerBlock(const std::string &block) } // Optionally parse the server block here std::string locationBlock = block.substr(bracePos + 1, closeBrace - bracePos - 1); - LOG_INFO("Added location: " + locationPath); + LOG_TRACE("Added location: " + locationPath); locations_.emplace(locationPath, locationBlock); pos = closeBrace + 1; } @@ -74,27 +74,27 @@ void ServerConfig::parseDirectives(const std::string &declarations) { throw std::runtime_error("Invalid port number: " + std::to_string(port_)); } - LOG_INFO("Set port to " + std::to_string(port_)); + LOG_TRACE("Set port to " + std::to_string(port_)); } else if (directive == "root") { root_ = value; - LOG_INFO("Set root to " + root_); + LOG_TRACE("Set root to " + root_); } else if (directive == "host") { host_ = value; - LOG_INFO("Set host to " + host_); + LOG_TRACE("Set host to " + host_); } else if (directive == "cgi_pass") { cgi_pass_ = value; - LOG_INFO("Set cgi_pass to " + cgi_pass_); + LOG_TRACE("Set cgi_pass to " + cgi_pass_); } else if (directive == "cgi_ext") { cgi_ext_ = value; - LOG_INFO("Set cgi_ext to " + cgi_ext_); + LOG_TRACE("Set cgi_ext to " + cgi_ext_); } else if (directive == "index") { @@ -103,7 +103,7 @@ void ServerConfig::parseDirectives(const std::string &declarations) while (lineStream >> indexFile) { index_files_.push_back(indexFile); - LOG_INFO("Added index file: " + indexFile); + LOG_TRACE("Added index file: " + indexFile); } } else if (directive == "error_page") @@ -111,8 +111,7 @@ void ServerConfig::parseDirectives(const std::string &declarations) int statusCode = std::stoi(value); std::string errorPagePath; lineStream >> errorPagePath; - error_page_[statusCode] = errorPagePath; - LOG_INFO("Set error_page for status " + std::to_string(statusCode) + " to " + errorPagePath); + LOG_TRACE("Set error_page for status " + std::to_string(statusCode) + " to " + errorPagePath); } else { diff --git a/webserv/main.cpp b/webserv/main.cpp index c1a6871..db763c1 100644 --- a/webserv/main.cpp +++ b/webserv/main.cpp @@ -1,8 +1,8 @@ -#include "webserv/log/Log.hpp" - #include #include #include +#include +#include #include #include