22#if ((DL_PLATFORM == DL_PLATFORM_WIN32))
24#include <source_location>
27#include <fmt/format.h>
32 "damage",
"err",
"warn",
"notice",
"msg",
"info",
"test",
"pause",
64 Setting& ret = _stackSetting.top();
65 _mutexSetting.unlock();
74 void SetLogFile(std::string_view path, std::string_view name = {});
87 _stackLevel.push(level);
97 bool ret = level > _stackLevel.top();
105 return level <= _levelMsgBox;
110 _levelMsgBox = level;
121 _mutexSetting.lock();
122 _stackSetting.push(setting);
141 _mutexSetting.unlock();
151 size_t index = (size_t)level;
157 std::stack<Setting> _stackSetting;
158 std::stack<Level> _stackLevel;
160 static std::string _logFile;
161 std::recursive_mutex _mutexSetting;
162 std::recursive_mutex _mutexLevel;
163 std::mutex _mutexOutput;
165extern LogSystem*
g_log;
173 g_log->PushLevelLimit(level);
177 g_log->PopLevelLimit();
201 printf(
"%s", str.data());
205#if ((DL_PLATFORM == DL_PLATFORM_WIN32))
209void log_pause0(std::string_view str,
const std::source_location location = std::source_location::current());
210void log_test0(std::string_view str,
const std::source_location location = std::source_location::current());
211void log_info0(std::string_view str,
const std::source_location location = std::source_location::current());
212void log_msg0(std::string_view str,
const std::source_location location = std::source_location::current());
213void log_notice0(std::string_view str,
const std::source_location location = std::source_location::current());
214void log_warn0(std::string_view str,
const std::source_location location = std::source_location::current());
215void log_err0(std::string_view str,
const std::source_location location = std::source_location::current());
216void log_damage0(std::string_view str,
const std::source_location location = std::source_location::current());
219void log(std::string_view str,
const std::source_location location = std::source_location::current());
221void log_err0(
const std::exception& e,
const std::source_location location = std::source_location::current());
222void log_err0(
const std::system_error& e,
const std::source_location location = std::source_location::current());
224#define log_(...) log(fmt::format(__VA_ARGS__), std::source_location::current())
225#define log_pause(...) log_pause0(fmt::format(__VA_ARGS__), std::source_location::current())
226#define log_test(...) log_test0(fmt::format(__VA_ARGS__), std::source_location::current())
227#define log_info(...) log_info0(fmt::format(__VA_ARGS__), std::source_location::current())
228#define log_msg(...) log_msg0(fmt::format(__VA_ARGS__), std::source_location::current())
229#define log_notice(...) log_notice0(fmt::format(__VA_ARGS__), std::source_location::current())
230#define log_warn(...) log_warn0(fmt::format(__VA_ARGS__), std::source_location::current())
231#define log_err(...) log_err0(fmt::format(__VA_ARGS__), std::source_location::current())
232#define log_damage(...) log_damage0(fmt::format(__VA_ARGS__), std::source_location::current())
237void log(std::string_view str);
240inline void log_test0(std::string_view str) {
log(str); }
241inline void log_info0(std::string_view str) {
log(str); }
242inline void log_msg0(std::string_view str) {
log(str); }
244inline void log_warn0(std::string_view str) {
log(str); }
245inline void log_err0(std::string_view str) {
log(str); }
248void log_err0(
const std::exception& e);
249void log_err0(
const std::system_error& e);
251#define log_(...) log(fmt::format(__VA_ARGS__))
252#define log_pause(...) log_pause0(fmt::format(__VA_ARGS__))
253#define log_test(...) log_test0(fmt::format(__VA_ARGS__))
254#define log_info(...) log_info0(fmt::format(__VA_ARGS__))
255#define log_msg(...) log_msg0(fmt::format(__VA_ARGS__))
256#define log_notice(...) log_notice0(fmt::format(__VA_ARGS__))
257#define log_warn(...) log_warn0(fmt::format(__VA_ARGS__))
258#define log_err(...) log_err0(fmt::format(__VA_ARGS__))
259#define log_damage(...) log_damage0(fmt::format(__VA_ARGS__))
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)
设置弹窗等级(小于等于自己才弹,越小越严重)
void log_msg0(std::string_view str, const std::source_location location=std::source_location::current())
void log_pause0(std::string_view str, const std::source_location location=std::source_location::current())
void log_notice0(std::string_view str, const std::source_location location=std::source_location::current())
constexpr std::array< std::string_view, 9 > DL_LOG_SYSTEM_LEVLE_NAME
void log_warn0(std::string_view str, const std::source_location location=std::source_location::current())
void log_easy(std::string_view str)
输出日志
void log_test0(std::string_view str, const std::source_location location=std::source_location::current())
void log(std::string_view str, const std::source_location location=std::source_location::current())
以当前设置输出
void log_info0(std::string_view str, const std::source_location location=std::source_location::current())
void log_err0(std::string_view str, const std::source_location location=std::source_location::current())
void log_damage0(std::string_view str, const std::source_location location=std::source_location::current())