diff --git a/src/libmain/loggers.cc b/src/libmain/loggers.cc index 836ea3dc8..07d83a960 100644 --- a/src/libmain/loggers.cc +++ b/src/libmain/loggers.cc @@ -50,11 +50,6 @@ void setLogFormat(const std::string & logFormatStr) void setLogFormat(const LogFormat & logFormat) { defaultLogFormat = logFormat; - createDefaultLogger(); -} - -void createDefaultLogger() -{ logger = makeDefaultLogger(); } diff --git a/src/libmain/loggers.hh b/src/libmain/loggers.hh index e5721420c..98b287fa7 100644 --- a/src/libmain/loggers.hh +++ b/src/libmain/loggers.hh @@ -16,6 +16,4 @@ enum class LogFormat { void setLogFormat(const std::string & logFormatStr); void setLogFormat(const LogFormat & logFormat); -void createDefaultLogger(); - } diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc index 17109b57e..4db49f02c 100644 --- a/src/libmain/progress-bar.cc +++ b/src/libmain/progress-bar.cc @@ -560,15 +560,4 @@ std::unique_ptr makeProgressBar() return std::make_unique(isTTY()); } -void startProgressBar() -{ - logger = makeProgressBar(); -} - -void stopProgressBar() -{ - if (auto progressBar = dynamic_cast(logger.get())) - progressBar->stop(); -} - } diff --git a/src/libmain/progress-bar.hh b/src/libmain/progress-bar.hh index 83209e863..fc1b0fe78 100644 --- a/src/libmain/progress-bar.hh +++ b/src/libmain/progress-bar.hh @@ -7,8 +7,4 @@ namespace nix { std::unique_ptr makeProgressBar(); -void startProgressBar(); - -void stopProgressBar(); - } diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 30e76c349..bc2ffc9ba 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -361,7 +361,7 @@ RunPager::RunPager() if (!pager) pager = getenv("PAGER"); if (pager && ((std::string) pager == "" || (std::string) pager == "cat")) return; - stopProgressBar(); + logger->stop(); Pipe toPager; toPager.create(); diff --git a/src/nix/build.cc b/src/nix/build.cc index 3569b0cde..4ba6241ec 100644 --- a/src/nix/build.cc +++ b/src/nix/build.cc @@ -3,7 +3,6 @@ #include "shared.hh" #include "store-api.hh" #include "local-fs-store.hh" -#include "progress-bar.hh" #include @@ -120,7 +119,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile createOutLinks(outLink, toBuiltPaths(buildables), *store2); if (printOutputPaths) { - stopProgressBar(); + logger->stop(); for (auto & buildable : buildables) { std::visit(overloaded { [&](const BuiltPath::Opaque & bo) { diff --git a/src/nix/cat.cc b/src/nix/cat.cc index e0179c348..214d256e9 100644 --- a/src/nix/cat.cc +++ b/src/nix/cat.cc @@ -1,7 +1,6 @@ #include "command.hh" #include "store-api.hh" #include "nar-accessor.hh" -#include "progress-bar.hh" using namespace nix; @@ -14,7 +13,7 @@ struct MixCat : virtual Args auto st = accessor->lstat(CanonPath(path)); if (st.type != SourceAccessor::Type::tRegular) throw Error("path '%1%' is not a regular file", path); - stopProgressBar(); + logger->stop(); writeFull(getStandardOutput(), accessor->readFile(CanonPath(path))); } diff --git a/src/nix/develop.cc b/src/nix/develop.cc index deee89aa1..961962ebd 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -7,7 +7,6 @@ #include "store-api.hh" #include "outputs-spec.hh" #include "derivations.hh" -#include "progress-bar.hh" #ifndef _WIN32 // TODO re-enable on Windows # include "run.hh" @@ -731,7 +730,7 @@ struct CmdPrintDevEnv : Common, MixJSON { auto buildEnvironment = getBuildEnvironment(store, installable).first; - stopProgressBar(); + logger->stop(); if (json) { logger->writeToStdout(buildEnvironment.toJSON()); diff --git a/src/nix/edit.cc b/src/nix/edit.cc index 9cbab230b..49807da9e 100644 --- a/src/nix/edit.cc +++ b/src/nix/edit.cc @@ -3,7 +3,6 @@ #include "shared.hh" #include "eval.hh" #include "attr-path.hh" -#include "progress-bar.hh" #include "editor-for.hh" #include @@ -40,7 +39,7 @@ struct CmdEdit : InstallableValueCommand } }(); - stopProgressBar(); + logger->stop(); auto args = editorFor(file, line); diff --git a/src/nix/eval.cc b/src/nix/eval.cc index 7811b77ed..e038d75c3 100644 --- a/src/nix/eval.cc +++ b/src/nix/eval.cc @@ -5,7 +5,6 @@ #include "eval.hh" #include "eval-inline.hh" #include "value-to-json.hh" -#include "progress-bar.hh" #include @@ -75,7 +74,7 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption } if (writeTo) { - stopProgressBar(); + logger->stop(); if (fs::symlink_exists(*writeTo)) throw Error("path '%s' already exists", writeTo->string()); @@ -114,7 +113,7 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption } else if (raw) { - stopProgressBar(); + logger->stop(); writeFull(getStandardOutput(), *state->coerceToString(noPos, *v, context, "while generating the eval command output")); } diff --git a/src/nix/log.cc b/src/nix/log.cc index 1a6f48f5e..2c35ed803 100644 --- a/src/nix/log.cc +++ b/src/nix/log.cc @@ -3,7 +3,6 @@ #include "shared.hh" #include "store-api.hh" #include "log-store.hh" -#include "progress-bar.hh" using namespace nix; @@ -55,7 +54,7 @@ struct CmdLog : InstallableCommand auto log = logSub.getBuildLog(path); if (!log) continue; - stopProgressBar(); + logger->stop(); printInfo("got build log for '%s' from '%s'", installable->what(), logSub.getUri()); writeFull(getStandardOutput(), *log); return; diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc index 84c0224e2..ba2fd39d8 100644 --- a/src/nix/prefetch.cc +++ b/src/nix/prefetch.cc @@ -4,7 +4,7 @@ #include "store-api.hh" #include "filetransfer.hh" #include "finally.hh" -#include "progress-bar.hh" +#include "loggers.hh" #include "tarfile.hh" #include "attr-path.hh" #include "eval-inline.hh" @@ -190,10 +190,7 @@ static int main_nix_prefetch_url(int argc, char * * argv) if (args.size() > 2) throw UsageError("too many arguments"); - Finally f([]() { stopProgressBar(); }); - - if (isTTY()) - startProgressBar(); + setLogFormat("bar"); auto store = openStore(); auto state = std::make_unique(myArgs.lookupPath, store, fetchSettings, evalSettings); @@ -247,7 +244,7 @@ static int main_nix_prefetch_url(int argc, char * * argv) auto [storePath, hash] = prefetchFile( store, resolveMirrorUrl(*state, url), name, ha, expectedHash, unpack, executable); - stopProgressBar(); + logger->stop(); if (!printPath) printInfo("path is '%s'", store->printStorePath(storePath)); diff --git a/src/nix/run.cc b/src/nix/run.cc index a9f9ef60f..897824d68 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -9,7 +9,6 @@ #include "local-fs-store.hh" #include "finally.hh" #include "source-accessor.hh" -#include "progress-bar.hh" #include "eval.hh" #include @@ -34,7 +33,7 @@ void execProgramInStore(ref store, const Strings & args, std::optional system) { - stopProgressBar(); + logger->stop(); restoreProcessContext(); diff --git a/src/nix/sigs.cc b/src/nix/sigs.cc index 134d4f34a..10b99b452 100644 --- a/src/nix/sigs.cc +++ b/src/nix/sigs.cc @@ -3,7 +3,6 @@ #include "shared.hh" #include "store-api.hh" #include "thread-pool.hh" -#include "progress-bar.hh" #include @@ -175,7 +174,7 @@ struct CmdKeyGenerateSecret : Command if (!keyName) throw UsageError("required argument '--key-name' is missing"); - stopProgressBar(); + logger->stop(); writeFull(getStandardOutput(), SecretKey::generate(*keyName).to_string()); } }; @@ -197,7 +196,7 @@ struct CmdKeyConvertSecretToPublic : Command void run() override { SecretKey secretKey(drainFD(STDIN_FILENO)); - stopProgressBar(); + logger->stop(); writeFull(getStandardOutput(), secretKey.toPublicKey().to_string()); } }; diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc index 1e8032af6..398e533ce 100644 --- a/src/nix/upgrade-nix.cc +++ b/src/nix/upgrade-nix.cc @@ -7,7 +7,6 @@ #include "eval-settings.hh" #include "attr-path.hh" #include "names.hh" -#include "progress-bar.hh" #include "executable-path.hh" #include "self-exe.hh" @@ -71,7 +70,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand auto version = DrvName(storePath.name()).version; if (dryRun) { - stopProgressBar(); + logger->stop(); warn("would upgrade to version %s", version); return; } @@ -89,7 +88,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand throw Error("could not verify that '%s' works", program); } - stopProgressBar(); + logger->stop(); { Activity act(*logger, lvlInfo, actUnknown, diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc index e299585ff..ae5c45ae3 100644 --- a/src/nix/why-depends.cc +++ b/src/nix/why-depends.cc @@ -1,6 +1,5 @@ #include "command.hh" #include "store-api.hh" -#include "progress-bar.hh" #include "source-accessor.hh" #include "shared.hh" @@ -110,8 +109,6 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions auto dependencyPath = *optDependencyPath; auto dependencyPathHash = dependencyPath.hashPart(); - stopProgressBar(); // FIXME - auto accessor = store->getFSAccessor(); auto const inf = std::numeric_limits::max();