22#if DL_PLATFORM == DL_PLATFORM_WIN32
24#include <source_location>
25#define DL_SOURCE_LOCATION std::source_location location = std::source_location::current()
26#define DL_SOURCE_LOCATION_IMP std::source_location location
27#define DL_SOURCE_LOCATION_CALL std::source_location::current()
28#define DL_SOURCE_LOCATION_FORWARD location
30#define DL_SOURCE_LOCATION const char* file = __FILE__, int line = __LINE__
31#define DL_SOURCE_LOCATION_IMP const char* file, int line
32#define DL_SOURCE_LOCATION_CALL __FILE__, __LINE__
33#define DL_SOURCE_LOCATION_FORWARD file, line
47#if DL_PLATFORM == DL_PLATFORM_WIN32
48#define DL_MAKE_SOURCE_LOCATION(loc) \
49 LogSourceLocation loc;\
50 loc._file = location.file_name();\
51 loc._func = location.function_name();\
52 loc._line = location.line();\
53 loc._column = location.column();
55#define DL_MAKE_SOURCE_LOCATION(loc) \
56 LogSourceLocation loc;\
58 loc._func = __func__;\
63#include <fmt/format.h>
68 "damage",
"err",
"warn",
"notice",
"msg",
"info",
"test",
"pause",
103 _mutexSetting.lock();
104 Setting& ret = _stackSetting.top();
105 _mutexSetting.unlock();
114 void SetLogFile(std::string_view path, std::string_view name = {});
127 _stackLevel.push(level);
132 _mutexLevel.unlock();
137 bool ret = level > _stackLevel.top();
138 _mutexLevel.unlock();
145 return level <= _levelMsgBox;
150 _levelMsgBox = level;
161 _mutexSetting.lock();
162 _stackSetting.push(setting);
181 _mutexSetting.unlock();
191 size_t index = (size_t)level;
197 std::stack<Setting> _stackSetting;
198 std::stack<Level> _stackLevel;
200 static std::string _logFile;
201 std::recursive_mutex _mutexSetting;
202 std::recursive_mutex _mutexLevel;
203 std::mutex _mutexOutput;
205extern LogSystem*
g_log;
213 g_log->PushLevelLimit(level);
217 g_log->PopLevelLimit();
241 printf(
"%s", str.data());
261#define log_(...) log(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
262#define log_pause(...) log_pause0(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
263#define log_test(...) log_test0(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
264#define log_info(...) log_info0(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
265#define log_msg(...) log_msg0(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
266#define log_notice(...) log_notice0(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
267#define log_warn(...) log_warn0(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
268#define log_err(...) log_err0(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
269#define log_damage(...) log_damage0(fmt::format(__VA_ARGS__), DL_SOURCE_LOCATION_CALL)
LogLimit(LogSystem::Level level=LogSystem::Level::DAMAGE)
默认为最高等级,用于屏蔽消息输出
LogStackTrack(bool open=true)
bool IsLevelLimit(Level level)
void PushLevelLimit(Level level)
设置日志输出等级
const Setting & GetSetting()
返回当前设置
void PushLevel(Level level)
入栈设置
void SetLogFile(std::string_view path, std::string_view name={})
设置日志文件路径(非线程安全)
static std::string_view Level2String(Level level)
日志等级转字符串
bool IsLevelMsgBox(Level level)
检查等级是否可以弹窗(小于等于自己)
void Push(const Setting &setting)
入栈设置
void SetLevelMsgBox(Level level)
设置弹窗等级(小于等于自己才弹,越小越严重)
#define DL_SOURCE_LOCATION
constexpr std::array< std::string_view, 9 > DL_LOG_SYSTEM_LEVLE_NAME
void log_msg0(std::string_view str, DL_SOURCE_LOCATION)
void log_easy(std::string_view str)
输出日志
void Output(std::string_view str)
打印到标准输出、vs、日志文件
void log(std::string_view str, DL_SOURCE_LOCATION)
以当前设置输出
void log_err0(std::string_view str, DL_SOURCE_LOCATION)
void log_info0(std::string_view str, DL_SOURCE_LOCATION)
void log_test0(std::string_view str, DL_SOURCE_LOCATION)
void log_pause0(std::string_view str, DL_SOURCE_LOCATION)
void log_warn0(std::string_view str, DL_SOURCE_LOCATION)
void log_notice0(std::string_view str, DL_SOURCE_LOCATION)
void log_damage0(std::string_view str, DL_SOURCE_LOCATION)