1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-01 08:28:00 +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() void applyJSONLogger()
{ {
if (!loggerSettings.jsonLogPath.get().empty()) { if (!loggerSettings.jsonLogPath.get().empty()) {
try {
std::vector<std::unique_ptr<Logger>> loggers; std::vector<std::unique_ptr<Logger>> loggers;
try {
loggers.push_back(std::move(logger)); loggers.push_back(std::move(logger));
loggers.push_back(makeJSONLogger(std::filesystem::path(loggerSettings.jsonLogPath.get()), false)); loggers.push_back(makeJSONLogger(std::filesystem::path(loggerSettings.jsonLogPath.get()), false));
logger = makeTeeLogger(std::move(loggers)); logger = makeTeeLogger(std::move(loggers));
} catch (...) { } catch (...) {
logger = std::move(loggers[0]);
ignoreExceptionExceptInterrupt(); ignoreExceptionExceptInterrupt();
} }
} }