ShitEngine 1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
Log类 参考

日志封装类 更多...

#include <Log.h>

Public 类型

using MessageCallback = std::function<void(bool isCore, int level, const std::string& message)>
 日志消息回调:isCore = 引擎日志(Shit)/ 用户日志(App);level = spdlog 等级;message = 文本

静态 Public 成员函数

static bool Init ()
template<typename... Args>
static void Trace (fmt::format_string< Args... > fmt, Args &&... args)
template<typename... Args>
static void Debug (fmt::format_string< Args... > fmt, Args &&... args)
template<typename... Args>
static void Info (fmt::format_string< Args... > fmt, Args &&... args)
template<typename... Args>
static void Warn (fmt::format_string< Args... > fmt, Args &&... args)
template<typename... Args>
static void Error (fmt::format_string< Args... > fmt, Args &&... args)
template<typename... Args>
static void Critical (fmt::format_string< Args... > fmt, Args &&... args)
static std::shared_ptr< spdlog::logger > & GetCoreLogger ()
static std::shared_ptr< spdlog::logger > & GetClientLogger ()
static void SetMessageCallback (MessageCallback cb)
 注册全局日志转发回调(Init 前/后均可;重新注册替换旧回调;传 nullptr 解除转发)
static const MessageCallback & GetMessageCallback ()
 当前回调(供引擎内部 sink 读取)
static void SetLogDirectory (const std::string &dir)
 设置文件日志目录(P32:编辑器打开项目后把日志写入项目 .shitengine/log) dir 为最终日志目录(引擎内部不再拼接子目录);空 = 恢复默认(进程工作目录/.shitengine/log)。 未初始化时仅记录,Init() 按新目录创建;已初始化时重建文件 sink(旧文件关闭、 新目录按当前时间新开归档文件)。幂等,可重复调用。

详细描述

日志封装类

成员类型定义说明

◆ MessageCallback

using MessageCallback = std::function<void(bool isCore, int level, const std::string& message)>

日志消息回调:isCore = 引擎日志(Shit)/ 用户日志(App);level = spdlog 等级;message = 文本

成员函数说明

◆ Critical()

template<typename... Args>
void Critical ( fmt::format_string< Args... > fmt,
Args &&... args )
inlinestatic

◆ Debug()

template<typename... Args>
void Debug ( fmt::format_string< Args... > fmt,
Args &&... args )
inlinestatic

◆ Error()

template<typename... Args>
void Error ( fmt::format_string< Args... > fmt,
Args &&... args )
inlinestatic

◆ GetClientLogger()

std::shared_ptr< spdlog::logger > & GetClientLogger ( )
inlinestatic

◆ GetCoreLogger()

std::shared_ptr< spdlog::logger > & GetCoreLogger ( )
inlinestatic

◆ GetMessageCallback()

const MessageCallback & GetMessageCallback ( )
inlinestatic

当前回调(供引擎内部 sink 读取)

◆ Info()

template<typename... Args>
void Info ( fmt::format_string< Args... > fmt,
Args &&... args )
inlinestatic

◆ Init()

bool Init ( )
static

◆ SetLogDirectory()

void SetLogDirectory ( const std::string & dir)
static

设置文件日志目录(P32:编辑器打开项目后把日志写入项目 .shitengine/log) dir 为最终日志目录(引擎内部不再拼接子目录);空 = 恢复默认(进程工作目录/.shitengine/log)。 未初始化时仅记录,Init() 按新目录创建;已初始化时重建文件 sink(旧文件关闭、 新目录按当前时间新开归档文件)。幂等,可重复调用。

◆ SetMessageCallback()

void SetMessageCallback ( MessageCallback cb)
static

注册全局日志转发回调(Init 前/后均可;重新注册替换旧回调;传 nullptr 解除转发)

◆ Trace()

template<typename... Args>
void Trace ( fmt::format_string< Args... > fmt,
Args &&... args )
inlinestatic

◆ Warn()

template<typename... Args>
void Warn ( fmt::format_string< Args... > fmt,
Args &&... args )
inlinestatic

该类的文档由以下文件生成:
  • include/ShitEngine/Core/Log.h