From 466115c9c893c28ef0fd8a96c75e7c7b76cc1bf5 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 24 Aug 2025 20:28:43 +0200 Subject: [PATCH] treewide: don't call Logger output functions directly always use log macros, which also have the benefit of respecting the verbosity setting without needing virtual function calls to read it. Change-Id: I1c605562a53e54140724d5225e040abcf49ac996 --- lix/libstore/build/derivation-goal.cc | 2 +- lix/libutil/current-process.cc | 19 ++++++++--------- lix/nix/doctor.cc | 2 +- lix/nix/flake.cc | 6 +++--- subprojects/nix-eval-jobs/src/constituents.cc | 21 +++++++------------ .../nix-eval-jobs/src/nix-eval-jobs.cc | 7 +++---- 6 files changed, 25 insertions(+), 32 deletions(-) diff --git a/lix/libstore/build/derivation-goal.cc b/lix/libstore/build/derivation-goal.cc index b39be6435..d03f6e8f7 100644 --- a/lix/libstore/build/derivation-goal.cc +++ b/lix/libstore/build/derivation-goal.cc @@ -1155,7 +1155,7 @@ try { std::shared_ptr remoteError; if (result.getResult().isBad()) { remoteError = std::make_shared(from(result.getResult().getBad())); - logger->logEI(remoteError->info()); + logErrorInfo(remoteError->info().level, remoteError->info()); } co_return HookResult::Accept{TRY_AWAIT(buildDone(remoteError))}; } catch (...) { diff --git a/lix/libutil/current-process.cc b/lix/libutil/current-process.cc index f3d77cfa0..b701f237f 100644 --- a/lix/libutil/current-process.cc +++ b/lix/libutil/current-process.cc @@ -61,16 +61,15 @@ void setStackSize(rlim_t stackSize) savedStackSize = limit.rlim_cur; limit.rlim_cur = std::min(stackSize, limit.rlim_max); if (setrlimit(RLIMIT_STACK, &limit) != 0) { - logger->log( - lvlError, - HintFmt( - "Failed to increase stack size from %1% to %2% (maximum allowed stack size: %3%): %4%", - savedStackSize, - stackSize, - limit.rlim_max, - std::strerror(errno) - ).str() - ); + printError(HintFmt( + "Failed to increase stack size from %1% to %2% (maximum allowed " + "stack size: %3%): %4%", + savedStackSize, + stackSize, + limit.rlim_max, + std::strerror(errno) + ) + .str()); } } } diff --git a/lix/nix/doctor.cc b/lix/nix/doctor.cc index 8bff10195..81faa6c61 100644 --- a/lix/nix/doctor.cc +++ b/lix/nix/doctor.cc @@ -61,7 +61,7 @@ struct CmdDoctor : StoreCommand void run(ref store) override { - logger->log("Running checks against store uri: " + store->getUri()); + printInfo("Running checks against store uri: " + store->getUri()); if (store.try_cast_shared()) { success &= checkNixInPath(); diff --git a/lix/nix/flake.cc b/lix/nix/flake.cc index c23cc5078..268975860 100644 --- a/lix/nix/flake.cc +++ b/lix/nix/flake.cc @@ -424,9 +424,9 @@ struct CmdFlakeCheck : FlakeCommand // FIXME: check meta attributes auto storePath = drvInfo->queryDrvPath(*state); if (storePath) { - logger->log(lvlInfo, - fmt("derivation evaluated to %s", - store->printStorePath(storePath.value()))); + printInfo( + "derivation evaluated to %s", store->printStorePath(storePath.value()) + ); } return storePath; } diff --git a/subprojects/nix-eval-jobs/src/constituents.cc b/subprojects/nix-eval-jobs/src/constituents.cc index 81983bd9d..04d377aaa 100644 --- a/subprojects/nix-eval-jobs/src/constituents.cc +++ b/subprojects/nix-eval-jobs/src/constituents.cc @@ -83,11 +83,9 @@ auto resolveNamedConstituents(const std::map &jobs) const nix::JSON &job) -> bool { if (job.find("error") != job.end()) { std::string error = job["error"]; - nix::logger->log( - nix::lvlError, - nix::fmt( - "aggregate job '%s' references broken job '%s': %s", - jobName, childJobName, error)); + printError( + "aggregate job '%s' references broken job '%s': %s", + jobName, childJobName, error); brokenJobs[childJobName] = error; return true; } @@ -97,10 +95,9 @@ auto resolveNamedConstituents(const std::map &jobs) for (const std::string childJobName : *named) { auto childJobIter = jobs.find(childJobName); if (childJobIter == jobs.end()) { - nix::logger->log(nix::lvlError, - nix::fmt("aggregate job '%s' references " - "non-existent job '%s'", - jobName, childJobName)); + printError( + "aggregate job '%s' references non-existent job '%s'", + jobName, childJobName); brokenJobs[childJobName] = "does not exist"; } else if (!isBroken(childJobName, childJobIter->second)) { results.insert(childJobName); @@ -156,10 +153,8 @@ void rewriteAggregates(std::map &jobs, register_gc_root(gcRootsDir, newDrvPathS, store, aio); - nix::logger->log(nix::lvlDebug, - nix::fmt("rewrote aggregate derivation %s -> %s", - store->printStorePath(drvPath), - newDrvPathS)); + printError("rewrote aggregate derivation %s -> %s", + store->printStorePath(drvPath), newDrvPathS); job["drvPath"] = newDrvPathS; job["outputs"]["out"] = store->printStorePath(outPath); diff --git a/subprojects/nix-eval-jobs/src/nix-eval-jobs.cc b/subprojects/nix-eval-jobs/src/nix-eval-jobs.cc index d672ed103..da85cb198 100644 --- a/subprojects/nix-eval-jobs/src/nix-eval-jobs.cc +++ b/subprojects/nix-eval-jobs/src/nix-eval-jobs.cc @@ -417,10 +417,9 @@ int main(int argc, char **argv) { myArgs.gcRootsDir, aio); }, [&](const DependencyCycle &e) { - nix::logger->log(nix::lvlError, - nix::fmt("Found dependency cycle " - "between jobs '%s' and '%s'", - e.a, e.b)); + printError( + "Found dependency cycle between jobs '%s' and '%s'", + e.a, e.b); state->jobs[e.a]["error"] = e.message(); state->jobs[e.b]["error"] = e.message();