143inline void COUT_(
const std::string& log_level,
const std::string& function,
int line,
const char* format_str, ...) {
146 va_start(args, format_str);
150 std::ostringstream logMsg;
153 if (log_level ==
"ERROR" || log_level ==
"FATAL") {
155 if (err > 0 && err < MAX_ENAME && ename[err][0] !=
'\0') {
156 std::ostringstream err_info;
157 err_info <<
" | errno=" << err <<
" (" << ename[err] <<
")";
158 strncat(buf, err_info.str().c_str(),
SQLOGD_BUF_SIZE - strlen(buf) - 1);
164 logMsg <<
"[" << log_level <<
"] [" <<
getTimeString() <<
"] (" << function <<
":" << line <<
") - " << buf <<
"\n";
166 logMsg <<
"[" << log_level <<
"] [" <<
getTimeString() <<
"] - " << buf <<
"\n";
171 std::lock_guard<std::mutex> lock(
log_mutex);
172 log_queue.push(logMsg.str());
178 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
179 if (log_level ==
"ERROR") SetConsoleTextAttribute(hConsole, 12);
180 else if (log_level ==
"FATAL") SetConsoleTextAttribute(hConsole, 206);
181 else if (log_level ==
"WARN") SetConsoleTextAttribute(hConsole, 14);
182 else if (log_level ==
"INFO") SetConsoleTextAttribute(hConsole, 10);
183 else SetConsoleTextAttribute(hConsole, 7);
186 std::cout << logMsg.str();
189 SetConsoleTextAttribute(hConsole, 7);
192 if (log_level ==
"FATAL") {
193 std::exit(EXIT_FAILURE);
void COUT_(const std::string &log_level, const std::string &function, int line, const char *format_str,...)
실제 로그 메시지를 포맷팅하고 출력합니다.
Definition log.hpp:143