| 56 | #endif |
| 57 | public: |
| 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; |
nothing calls this directly
no test coverage detected