| 397 | } |
| 398 | |
| 399 | void setupLogging(const std::filesystem::path& logDir, std::string_view appName) |
| 400 | { |
| 401 | Log::sMinDebugLevel = getDebugLevel(); |
| 402 | Log::sWriteLevel = true; |
| 403 | |
| 404 | #if !(defined(_WIN32) && defined(_DEBUG)) |
| 405 | const std::string logName = Misc::StringUtils::lowerCase(appName) + ".log"; |
| 406 | logfile.open(logDir / logName, std::ios::out); |
| 407 | |
| 408 | Identity log(logfile); |
| 409 | |
| 410 | for (const Record& v : globalBuffer) |
| 411 | log.write(v.mValue.data(), v.mValue.size(), v.mLevel); |
| 412 | |
| 413 | globalBuffer.clear(); |
| 414 | |
| 415 | standardOut.open(Tee(log, Coloured(*rawStdout))); |
| 416 | standardErr.open(Tee(log, Coloured(*rawStderr))); |
| 417 | |
| 418 | std::cout.rdbuf(&standardOut); |
| 419 | std::cerr.rdbuf(&standardErr); |
| 420 | #endif |
| 421 | |
| 422 | #ifdef _WIN32 |
| 423 | if (Crash::CrashCatcher::instance()) |
| 424 | { |
| 425 | Crash::CrashCatcher::instance()->updateDumpPath(logDir); |
| 426 | } |
| 427 | #endif |
| 428 | } |
| 429 | |
| 430 | int wrapApplication( |
| 431 | int (*innerApplication)(int argc, char* argv[]), int argc, char* argv[], std::string_view appName) |
no test coverage detected