Files
Rcjy/Rcjy/Framework/Backend/Console/Log/Log.h
T
2026-06-08 15:49:35 +08:00

39 lines
994 B
C++

#pragma once
#include <Windows.h>
#include <cstdarg>
#include <cstdio>
#include <string>
enum class LogLevel { Info, Warning, Error };
class Log
{
public:
static Log* Get();
void Info(const wchar_t* fmt, ...);
void Warning(const wchar_t* fmt, ...);
void Error(const wchar_t* fmt, ...);
// Redirect raylib trace logs through our Log so the console guard
// thread detects blocking on ALL output, not just our own.
static void RedirectRaylibTrace();
private:
Log();
~Log();
void Write(LogLevel level, const wchar_t* fmt, va_list args);
void WriteRaw(LogLevel level, const wchar_t* msg);
void SetColor(LogLevel level);
void ResetColor();
// Callback for RLSetTraceLogCallback — formats ANSI text, converts
// to wide, and routes through the normal Write path.
static void RaylibTraceCallback(int logLevel, const char* text, va_list args);
HANDLE m_hOut = NULL;
FILE* m_fp = NULL;
CRITICAL_SECTION m_cs;
};