diff --git a/src/Request.cpp b/src/Request.cpp index f0a46c6..76b882c 100644 --- a/src/Request.cpp +++ b/src/Request.cpp @@ -144,9 +144,18 @@ static std::string method_to_string(webcxx::RequestType method) { } } +static std::string remove_trailing_newline(std::string str) +{ + while(str[str.size() - 1] == '\n') + { + str.pop_back(); + } + return std::move(str); +} + void webcxx::Request::log(int status_code) { time_t current_time = time(NULL); - printf("(%s) %s - \"%s %s HTTP/1.1\" - %d\n", ctime(¤t_time), m_ip.c_str(), + printf("(%s) %s - \"%s %s HTTP/1.1\" - %d\n", remove_trailing_newline(ctime(¤t_time)).c_str(), m_ip.c_str(), method_to_string(m_method).c_str(), m_real_path.c_str(), status_code);