44#include " core/signals.hpp"
55#include " http/http_parser.hpp"
66#include " router/router.hpp"
7+ #include " util/log_message.hpp"
78#include " util/syscall_error.hpp"
89
910#include < errno.h>
@@ -85,7 +86,7 @@ void Server::close_connection(Client& conn)
8586
8687 std::map<uint64_t , Client*>::iterator it = clients_.find (client_id);
8788 if (it == clients_.end ()) {
88- std::cerr << " [WARNING] Attempted to remove inexistant client id" << std::endl ;
89+ LOG (WARN) << " Attempted to remove inexistand client id" ;
8990 return ;
9091 }
9192
@@ -97,7 +98,7 @@ Client& Server::get_client(uint64_t id)
9798{
9899 std::map<uint64_t , Client*>::iterator it = clients_.find (id);
99100 if (it == clients_.end ()) {
100- throw std::runtime_error (" [FATAL] Attempted to retrieve inexistant client id" );
101+ throw std::runtime_error (" Attempted to retrieve inexistant client id" );
101102 }
102103 return *(it->second );
103104}
@@ -121,7 +122,7 @@ void Server::accept_connection()
121122 ev.data .u64 = client_id;
122123 epoll_ctl (epoll_fd_, EPOLL_CTL_ADD, client_fd, &ev);
123124
124- std::cout << " * Connection established, client_id = " << client_id << std::endl ;
125+ LOG (INFO) << " Client # " << client_id << " connected " ;
125126}
126127
127128void Server::run ()
@@ -135,8 +136,7 @@ void Server::run()
135136 // nothing happened.
136137 n_events = 0 ;
137138 break ;
138- default :
139- throw UnrecoverableError (" epoll_wait" , errno);
139+ default : throw UnrecoverableError (" epoll_wait" , errno);
140140 }
141141 }
142142
@@ -193,7 +193,7 @@ void Server::handle_events(Client& conn, uint32_t events)
193193 return ;
194194 }
195195
196- std::cout << " * Received data from socket " << std::endl ;
196+ LOG (DEBUG) << " Received " << bytes_received << " bytes from socket " ;
197197 print_raw_data (tmp);
198198
199199 // Feed data to the parser
0 commit comments