MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / Logger

Method Logger

Source/Common/Debug.cpp:58–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56#endif
57public:
58 Logger() {
59 _thread = SharedAsyncThread.newThread();
60 _formatter.set_pattern("[%H:%M:%S.%e] [%l] %v"s);
61#if BX_PLATFORM_ANDROID
62 auto consoleSink = std::make_shared<spdlog::sinks::android_sink_mt>("dora"s);
63#else
64 Mutex::mutexPtr = &_mutex;
65 auto consoleSink = std::make_shared<spdlog::sinks::ansicolor_stdout_sink<Mutex>>();
66#endif
67 auto doraSink = std::make_shared<spdlog::sinks::callback_sink_mt>([this](const spdlog::details::log_msg& msg) {
68 spdlog::memory_buf_t buf;
69 _formatter.format(msg, buf);
70 auto str = fmt::to_string(buf);
71 if (Singleton<Dora::Application>::isInitialized() && SharedApplication.isLogicRunning()) {
72 SharedApplication.invokeInLogic([str]() {
73 LogHandler(str);
74 });
75 }
76 });
77#if BX_PLATFORM_WINDOWS
78 auto logFilename = u8_to_w(getFilename());
79#else
80 auto logFilename = getFilename();
81#endif
82 auto fileSink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(logFilename, getMaxFileSize(), getMaxFiles());
83 _logger = std::make_shared<spdlog::logger>(std::string(), spdlog::sinks_init_list{consoleSink, doraSink, fileSink});
84 }
85
86 int getMaxFiles() const {
87 return 2;

Callers

nothing calls this directly

Calls 7

stringFunction · 0.85
newThreadMethod · 0.80
isLogicRunningMethod · 0.80
invokeInLogicMethod · 0.80
formatMethod · 0.65
to_stringFunction · 0.50
set_patternMethod · 0.45

Tested by

no test coverage detected