diff --git a/webserv/client/Client.cpp b/webserv/client/Client.cpp index 5539f46..bba52d0 100644 --- a/webserv/client/Client.cpp +++ b/webserv/client/Client.cpp @@ -18,11 +18,12 @@ Client::Client(std::unique_ptr socket, Server &server) : client_socket_(std::move(socket)), server_(std::ref(server)), httpRequest_(std::make_unique(this)) { + Log::info("New client connected, fd: " + std::to_string(client_socket_->getFd())); } Client::~Client() { - Log::debug("Client destructor called for fd: " + std::to_string(client_socket_->getFd())); + Log::info("Client disconnected, fd: " + std::to_string(client_socket_->getFd())); server_.removeFromEpoll(*client_socket_); }; @@ -48,7 +49,7 @@ void Client::request() } if (bytesRead == 0) { - Log::info("Client disconnected, fd: " + std::to_string(client_socket_->getFd())); + Log::info("Client disconnected, fd: " + std::to_string(client_socket_->getFd())); //TODO weird return; } @@ -102,7 +103,7 @@ std::string Client::getResponse() const body += "Server port " + std::to_string(port) + "\r\n"; response += "Content-Length: " + std::to_string(body.size()) + "\r\n\r\n"; response += body; - + Log::info("Prepared response for client fd: " + std::to_string(client_socket_->getFd())); Log::debug("Sending response:\n" + response); return response; } \ No newline at end of file diff --git a/webserv/config/AConfig.cpp b/webserv/config/AConfig.cpp index 5ec043e..338850b 100644 --- a/webserv/config/AConfig.cpp +++ b/webserv/config/AConfig.cpp @@ -64,7 +64,7 @@ void AConfig::parseDirectives(const std::string &declarations) { continue; } - Log::info("Global Declaration: " + line); + Log::debug("Global Declaration: " + line); addDirective(line); } } diff --git a/webserv/config/ConfigManager.cpp b/webserv/config/ConfigManager.cpp index 69762cc..7b98c74 100644 --- a/webserv/config/ConfigManager.cpp +++ b/webserv/config/ConfigManager.cpp @@ -28,7 +28,7 @@ void ConfigManager::init(const std::string &filePath) Log::warning("ConfigManager is already initialized."); throw std::runtime_error("ConfigManager is already initialized."); } - Log::info("Initializing ConfigManager with file: " + filePath); + Log::debug("Initializing ConfigManager with file: " + filePath); parseConfigFile(filePath); initialized_ = true; } @@ -36,7 +36,7 @@ void ConfigManager::init(const std::string &filePath) void ConfigManager::parseConfigFile(const std::string &filePath) { // Placeholder for actual file parsing logic - Log::info("Parsing configuration file: " + filePath); + Log::debug("Parsing configuration file: " + filePath); // Implement the parsing logic here std::ifstream file(filePath); diff --git a/webserv/main.cpp b/webserv/main.cpp index b548761..3c3f23f 100644 --- a/webserv/main.cpp +++ b/webserv/main.cpp @@ -16,9 +16,8 @@ int main(int argc, char **argv) return 1; } Log::setFileChannel("webserv.log", std::ios_base::app, Log::Level::Trace); - Log::setStdoutChannel(Log::Level::Trace); + Log::setStdoutChannel(Log::Level::Info); Log::info("\n======================\nStarting webserv...\n======================\n"); - Log::warning("Testing context: " + LOCATION, {{"key1", "value1"}, {"key2", "value2"}}); ConfigManager::getInstance().init(argv[1]); // NOLINT ConfigManager &configManager = ConfigManager::getInstance(); Log::info("ConfigManager initialized successfully."); diff --git a/webserv/server/Server.cpp b/webserv/server/Server.cpp index 83d0eec..b180237 100644 --- a/webserv/server/Server.cpp +++ b/webserv/server/Server.cpp @@ -166,7 +166,7 @@ void Server::handleRequest(struct epoll_event *event) const void Server::responseReady(int client_fd) const { - Log::info("Response ready for client fd: " + std::to_string(client_fd)); + Log::debug("Response ready for client fd: " + std::to_string(client_fd)); struct epoll_event ev{}; ev.events = EPOLLOUT; ev.data.fd = client_fd; @@ -179,7 +179,7 @@ void Server::responseReady(int client_fd) const void Server::eventLoop() { - Log::info("Entering event loop..."); + Log::info("Listening..."); const int MAX_EVENTS = 10; struct epoll_event events[MAX_EVENTS]; // NOLINT while (true) @@ -209,7 +209,7 @@ void Server::eventLoop() } else if ((event.events & EPOLLOUT) > 0) { - Log::info("Attempting to send data to fd: " + std::to_string(event.data.fd)); + Log::debug("Attempting to send data to fd: " + std::to_string(event.data.fd)); Client &client = getClient(event.data.fd); std::string response = client.getResponse(); const char *httpResponse = response.c_str(); @@ -221,7 +221,7 @@ void Server::eventLoop() } else { - Log::info("Sent " + std::to_string(bytesSent) + " bytes to fd: " + std::to_string(event.data.fd)); + Log::debug("Sent " + std::to_string(bytesSent) + " bytes to fd: " + std::to_string(event.data.fd)); } clients_.erase(event.data.fd); }