1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 19:57:59 +02:00

Don't segfault if we can't create the JSON logger

This commit is contained in:
Eelco Dolstra 2025-03-27 13:54:07 +01:00
parent 17d0810a7c
commit eca002ddc4

View file

@ -344,12 +344,13 @@ std::unique_ptr<Logger> makeJSONLogger(const std::filesystem::path & path, bool
void applyJSONLogger()
{
if (!loggerSettings.jsonLogPath.get().empty()) {
std::vector<std::unique_ptr<Logger>> loggers;
try {
std::vector<std::unique_ptr<Logger>> loggers;
loggers.push_back(std::move(logger));
loggers.push_back(makeJSONLogger(std::filesystem::path(loggerSettings.jsonLogPath.get()), false));
logger = makeTeeLogger(std::move(loggers));
} catch (...) {
logger = std::move(loggers[0]);
ignoreExceptionExceptInterrupt();
}
}