| 323 | } |
| 324 | |
| 325 | void LogImpl(const char *log_buf, const size_t log_buf_len) { |
| 326 | ScopedLock lk(g_LogLock); |
| 327 | |
| 328 | const auto thread_name = GetThreadName(); |
| 329 | std::string cur_time = "..."; |
| 330 | if(g_Settings.json_settings.general.has_value() && g_Settings.json_settings.general.value().use_12h_time.has_value()) { |
| 331 | cur_time = hos::GetCurrentTime(g_Settings.json_settings.general.value().use_12h_time.value()); |
| 332 | } |
| 333 | const auto log_str = "[" + cur_time + "] [" + thread_name + "] " + std::string(log_buf, log_buf_len); |
| 334 | |
| 335 | // To ensure no race conditions, use plain FS functions instead of the explorers |
| 336 | auto log_file = fopen("sdmc:/" GLEAF_PATH_LOG_FILE, "a+"); |
| 337 | if(log_file != nullptr) { |
| 338 | fwrite(log_str.c_str(), 1, log_str.length(), log_file); |
| 339 | fclose(log_file); |
| 340 | } |
| 341 | } |
nothing calls this directly
no test coverage detected