ImSQL
C++ 기반 SQL 자동화 및 라이선스 관리 엔진
Loading...
Searching...
No Matches
log.hpp File Reference

통합 로깅 유틸리티를 제공하는 헤더 파일입니다. More...

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <ctime>
#include <cstdarg>
#include <mutex>
#include <format>
#include <thread>
#include <queue>
#include <condition_variable>
#include <filesystem>
#include <unistd.h>
#include <sys/stat.h>
+ Include dependency graph for log.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SQLOG_H
 
#define SQLOGD_BUF_SIZE   4096
 로깅 버퍼 크기
 
#define RESOURCE_PATH   "./output"
 로그 파일 저장 디렉토리
 
#define SQLOG_I(format_str, ...)
 
#define SQLOG_E(format_str, ...)
 
#define SQLOG_F(format_str, ...)
 
#define SQLOG_D(format_str, ...)
 
#define SQLOG_W(format_str, ...)
 

Functions

std::string utils::getTimeString ()
 현재 시스템 시간을 문자열로 반환합니다.
 
void utils::ensureDirectoryExists (const std::string &dirPath)
 디렉토리가 존재하지 않으면 생성합니다.
 
std::string utils::getLogFilePath (const std::string &level)
 로그 파일 경로를 가져옵니다.
 
void utils::logThreadFunc ()
 백그라운드 로그 스레드 함수.
 
std::thread utils::log_thread (logThreadFunc)
 로그 스레드를 실행합니다.
 
void utils::COUT_ (const std::string &log_level, const std::string &function, int line, const char *format_str,...)
 실제 로그 메시지를 포맷팅하고 출력합니다.
 
void utils::stopLogThread ()
 로그 스레드를 중지하고 종료합니다.
 

Variables

std::mutex utils::log_mutex
 로깅 시스템 유틸리티 함수 및 전역 변수 모음.
 
std::queue< std::string > utils::log_queue
 
std::condition_variable utils::log_cv
 
bool utils::log_thread_running = true
 

Detailed Description

통합 로깅 유틸리티를 제공하는 헤더 파일입니다.

Function Documentation

◆ COUT_()

void utils::COUT_ ( const std::string & log_level,
const std::string & function,
int line,
const char * format_str,
... )
inline

실제 로그 메시지를 포맷팅하고 출력합니다.

Parameters
log_level로그 레벨 ("INFO", "ERROR" 등)
function호출한 함수 이름
line호출한 코드 라인
format_str출력할 문자열 포맷
...가변 인자

◆ ensureDirectoryExists()

void utils::ensureDirectoryExists ( const std::string & dirPath)
inline

디렉토리가 존재하지 않으면 생성합니다.

Parameters
dirPath생성할 디렉토리 경로

◆ getLogFilePath()

std::string utils::getLogFilePath ( const std::string & level)
inline

로그 파일 경로를 가져옵니다.

Parameters
level로그 레벨 (ex: "INFO", "ERROR")
Returns
파일 경로 문자열

◆ getTimeString()

std::string utils::getTimeString ( )
inline

현재 시스템 시간을 문자열로 반환합니다.

Returns
"YYYY-MM-DD HH:MM:SS" 형식의 시간 문자열

◆ logThreadFunc()

void utils::logThreadFunc ( )
inline

백그라운드 로그 스레드 함수.

로그 큐를 비우면서 파일에 저장합니다.

Variable Documentation

◆ log_mutex

std::mutex utils::log_mutex
inline

로깅 시스템 유틸리티 함수 및 전역 변수 모음.

  • 비동기 파일 로깅
  • 콘솔 컬러 출력 (Windows 지원)
  • 에러 코드(errno) 자동 출력 (디버그 모드)