From 1c034c465c337a05beab09069d9828f6f63f6032 Mon Sep 17 00:00:00 2001 From: 3lswear Date: Sun, 6 Mar 2022 13:44:14 +0300 Subject: [PATCH] fix: misc --- src/CGI/CgiHandle.cpp | 4 +++- src/Server/ServerConfig.cpp | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/CGI/CgiHandle.cpp b/src/CGI/CgiHandle.cpp index d4c94b1..5be25ca 100644 --- a/src/CGI/CgiHandle.cpp +++ b/src/CGI/CgiHandle.cpp @@ -115,7 +115,9 @@ std::string CgiHandle::executeCgi() dup2(fdin, STDIN_FILENO); dup2(fdOut, STDOUT_FILENO); execve(_response.getCgiPass().c_str(), argv, env); - std::cerr << WARNING << getDebugTime() << FAIL << " Execve error." << ENDL; + std::cerr << getDebugTime() << FAIL; + perror(" Execve error"); + std::cerr << RESET; write(STDOUT_FILENO, "Status: 500\r\n\r\n", 15); exit(1); } diff --git a/src/Server/ServerConfig.cpp b/src/Server/ServerConfig.cpp index 8ef2a44..5029dcd 100644 --- a/src/Server/ServerConfig.cpp +++ b/src/Server/ServerConfig.cpp @@ -22,14 +22,17 @@ std::string getDebugTime(void) { time_t rawtime; struct tm *timeinfo; - char buf[32]; time(&rawtime); timeinfo = localtime(&rawtime); - int tmp = strftime(buf, 32, "%T", timeinfo); - buf[tmp] = '\0'; - std::string ret = std::string(buf); + std::string ret = std::string(asctime(timeinfo)); + for (size_t i = 0; i < 3; i++) + { + ret.erase(0, ret.find(" ") + 1); + } + ret.erase(ret.find(" ")); + ret = std::string(WARNING) + "[ " + ret + " ] " + std::string(RESET) + std::string(OKCYAN);