mirror of
https://github.com/NixOS/nix
synced 2025-06-28 09:31:16 +02:00
Cleanup
This commit is contained in:
parent
c8692b378b
commit
17d0810a7c
4 changed files with 18 additions and 21 deletions
|
@ -1050,17 +1050,7 @@ void processConnection(
|
|||
if (!recursive) {
|
||||
prevLogger_ = std::move(logger);
|
||||
logger = std::move(tunnelLogger_);
|
||||
|
||||
if (!loggerSettings.jsonLogPath.get().empty()) {
|
||||
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 (...) {
|
||||
ignoreExceptionExceptInterrupt();
|
||||
}
|
||||
}
|
||||
applyJSONLogger();
|
||||
}
|
||||
|
||||
unsigned int opCount = 0;
|
||||
|
|
|
@ -341,6 +341,20 @@ std::unique_ptr<Logger> makeJSONLogger(const std::filesystem::path & path, bool
|
|||
return std::make_unique<JSONFileLogger>(std::move(fd), includeNixPrefix);
|
||||
}
|
||||
|
||||
void applyJSONLogger()
|
||||
{
|
||||
if (!loggerSettings.jsonLogPath.get().empty()) {
|
||||
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 (...) {
|
||||
ignoreExceptionExceptInterrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Logger::Fields getFields(nlohmann::json & json)
|
||||
{
|
||||
Logger::Fields fields;
|
||||
|
|
|
@ -221,6 +221,8 @@ std::unique_ptr<Logger> makeJSONLogger(Descriptor fd, bool includeNixPrefix = tr
|
|||
|
||||
std::unique_ptr<Logger> makeJSONLogger(const std::filesystem::path & path, bool includeNixPrefix = true);
|
||||
|
||||
void applyJSONLogger();
|
||||
|
||||
/**
|
||||
* @param source A noun phrase describing the source of the message, e.g. "the builder".
|
||||
*/
|
||||
|
|
|
@ -487,16 +487,7 @@ void mainWrapped(int argc, char * * argv)
|
|||
if (!args.helpRequested && !args.completions) throw;
|
||||
}
|
||||
|
||||
if (!loggerSettings.jsonLogPath.get().empty()) {
|
||||
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 (...) {
|
||||
ignoreExceptionExceptInterrupt();
|
||||
}
|
||||
}
|
||||
applyJSONLogger();
|
||||
|
||||
if (args.helpRequested) {
|
||||
std::vector<std::string> subcommand;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue