Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcmd/installable-flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ InstallableFlake::InstallableFlake(

DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
{
Activity act(*logger, lvlTalkative, actUnknown, fmt("evaluating derivation '%s'", what()));
Activity act(*logger, Verbosity::Talkative, actUnknown, fmt("evaluating derivation '%s'", what()));

auto attr = getCursor(*state);

Expand Down
6 changes: 3 additions & 3 deletions src/libcmd/installables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static void throwBuildErrors(std::vector<KeyedBuildResult> & buildResults, const
if (!failedResult->second->errorMsg.empty()) {
logError(
ErrorInfo{
.level = lvlError,
.level = Verbosity::Error,
.msg = failedResult->second->errorMsg,
});
}
Expand Down Expand Up @@ -623,7 +623,7 @@ std::vector<std::pair<ref<Installable>, BuiltPathWithResult>> Installable::build

case Realise::Nothing:
case Realise::Derivation:
printMissing(store, pathsToBuild, lvlError);
printMissing(store, pathsToBuild, Verbosity::Error);

for (auto & path : pathsToBuild) {
for (auto & aux : backmap[path]) {
Expand Down Expand Up @@ -653,7 +653,7 @@ std::vector<std::pair<ref<Installable>, BuiltPathWithResult>> Installable::build

case Realise::Outputs: {
if (settings.printMissing)
printMissing(store, pathsToBuild, lvlInfo);
printMissing(store, pathsToBuild, Verbosity::Info);

auto buildResults = store->buildPathsWithResults(pathsToBuild, bMode, evalStore);
throwBuildErrors(buildResults, *store);
Expand Down
4 changes: 2 additions & 2 deletions src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ ReplExitStatus NixRepl::mainLoop()
} catch (IncompleteReplExpr &) {
continue;
} catch (Error & e) {
printMsg(lvlError, e.msg());
printMsg(Verbosity::Error, e.msg());
} catch (Interrupted & e) {
printMsg(lvlError, e.msg());
printMsg(Verbosity::Error, e.msg());
}

// We handled the current input fully, so we should clear it
Expand Down
6 changes: 3 additions & 3 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr &
if (error) {
printError("%s\n", error->what());

if (trylevel > 0 && error->info().level != lvlInfo)
if (trylevel > 0 && error->info().level != Verbosity::Info)
printError(
"This exception occurred in a 'tryEval' call. Use " ANSI_GREEN "--ignore-try" ANSI_NORMAL
" to skip these.\n");
Expand Down Expand Up @@ -2509,7 +2509,7 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat
repair);
allowPath(dstPath);
srcToStore->try_emplace(path, dstPath);
printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
printMsg(Verbosity::Chatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
return dstPath;
}();

Expand Down Expand Up @@ -3133,7 +3133,7 @@ Expr * EvalState::parseStdin()
// NOTE this method (and parseExprFromString) must take care to *fully copy* their
// input into their respective Pos::Origin until the parser stops overwriting its
// input data.
// Activity act(*logger, lvlTalkative, "parsing standard input");
// Activity act(*logger, Verbosity::Talkative, "parsing standard input");
auto buffer = drainFD(0);
// drainFD should have left some extra space for terminators
buffer.append("\0\0", 2);
Expand Down
4 changes: 2 additions & 2 deletions src/libexpr/function-trace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ void FunctionCallTrace::preFunctionCallHook(
{
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
printMsg(lvlInfo, "function-trace entered %1% at %2%", state.positions[pos], ns.count());
printMsg(Verbosity::Info, "function-trace entered %1% at %2%", state.positions[pos], ns.count());
}

void FunctionCallTrace::postFunctionCallHook(
EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
{
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
printMsg(lvlInfo, "function-trace exited %1% at %2%", state.positions[pos], ns.count());
printMsg(Verbosity::Info, "function-trace exited %1% at %2%", state.positions[pos], ns.count());
}

} // namespace nix
6 changes: 3 additions & 3 deletions src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ static RegisterPrimOp primop_break(
if (state.canDebug()) {
auto error = Error(
ErrorInfo{
.level = lvlInfo,
.level = Verbosity::Info,
.msg = HintFmt("breakpoint reached"),
.pos = state.positions[pos],
});
Expand Down Expand Up @@ -1278,7 +1278,7 @@ static void prim_warn(EvalState & state, const PosIdx pos, Value ** args, Value
BaseError msg(std::string{msgStr});
msg.atPos(state.positions[pos]);
auto info = msg.info();
info.level = lvlWarn;
info.level = Verbosity::Warn;
info.isFromExpr = true;
logWarning(info);
}
Expand Down Expand Up @@ -1781,7 +1781,7 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName
auto drvPath = writeDerivation(*state.store, drv, state.repair);
auto drvPathS = state.store->printStorePath(drvPath);

printMsg(lvlChatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS);
printMsg(Verbosity::Chatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS);

/* Optimisation, but required in read-only mode! because in that
case we don't actually write store derivations, so we can't
Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/fetch-to-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ StorePath fetchToStore(

Activity act(
*logger,
lvlChatty,
Verbosity::Chatty,
actUnknown,
fmt(mode == FetchMode::DryRun ? "hashing '%s'" : "copying '%s' to the store", path));

Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/fetchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void InputScheme::clone(

auto [accessor, input2] = getAccessor(settings, store, input);

Activity act(*logger, lvlTalkative, actUnknown, fmt("copying '%s' to %s...", input2.to_string(), destDir));
Activity act(*logger, Verbosity::Talkative, actUnknown, fmt("copying '%s' to %s...", input2.to_string(), destDir));

RestoreSink sink(/*startFsync=*/false);
sink.dstPath = destDir;
Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/git-lfs-fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ std::vector<nlohmann::json> Fetch::fetchUrls(const std::vector<Pointer> & pointe

return objects;
} catch (const nlohmann::json::parse_error & e) {
printMsg(lvlTalkative, "Full response: '%1%'", responseString);
printMsg(Verbosity::Talkative, "Full response: '%1%'", responseString);
throw Error("response did not parse as json: %s", e.what());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/git-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>

void fetch(const std::string & url, const std::string & refspec, bool shallow) override
{
Activity act(*logger, lvlTalkative, actFetchTree, fmt("fetching Git repository '%s'", url));
Activity act(*logger, Verbosity::Talkative, actFetchTree, fmt("fetching Git repository '%s'", url));

// TODO: implement git-credential helper support (preferably via libgit2, which as of 2024-01 does not support
// that)
Expand Down
5 changes: 4 additions & 1 deletion src/libfetchers/git.cc
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,10 @@ struct GitInputScheme : InputScheme
return getIntAttr(*revCountAttrs, "revCount");

Activity act(
*logger, lvlChatty, actUnknown, fmt("getting Git revision count of '%s'", repoInfo.locationToArg()));
*logger,
Verbosity::Chatty,
actUnknown,
fmt("getting Git revision count of '%s'", repoInfo.locationToArg()));

auto revCount = GitRepo::openRepo(repoDir)->getRevCount(rev);

Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/github.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ struct GitArchiveInputScheme : InputScheme
});

auto act = std::make_unique<Activity>(
*logger, lvlInfo, actUnknown, fmt("unpacking '%s' into the Git cache", input.to_string()));
*logger, Verbosity::Info, actUnknown, fmt("unpacking '%s' into the Git cache", input.to_string()));

TarArchive archive{*source};
auto tarballCache = settings.getTarballCache();
Expand Down
3 changes: 2 additions & 1 deletion src/libfetchers/mercurial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ struct MercurialInputScheme : InputScheme
&& runProgram(hgOptions({"log", "-R", cacheDir, "-r", input.getRev()->gitRev(), "--template", "1"}))
.second
== "1")) {
Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching Mercurial repository '%s'", actualUrl));
Activity act(
*logger, Verbosity::Talkative, actUnknown, fmt("fetching Mercurial repository '%s'", actualUrl));

if (pathExists(cacheDir)) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct PathInputScheme : InputScheme

time_t mtime = 0;
if (!storePath || storePath->name() != "source" || !store.isValidPath(*storePath)) {
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying %s to the store", absPath));
Activity act(*logger, Verbosity::Talkative, actUnknown, fmt("copying %s to the store", absPath));
// FIXME: try to substitute storePath.
auto src = sinkToSource(
[&](Sink & sink) { mtime = dumpPathAndGetMtime(absPath.string(), sink, defaultPathFilter); });
Expand Down
3 changes: 2 additions & 1 deletion src/libfetchers/tarball.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ static DownloadTarballResult downloadTarball_(

// TODO: fall back to cached value if download fails.

auto act = std::make_unique<Activity>(*logger, lvlInfo, actUnknown, fmt("unpacking '%s' into the Git cache", url));
auto act =
std::make_unique<Activity>(*logger, Verbosity::Info, actUnknown, fmt("unpacking '%s' into the Git cache", url));

AutoDelete cleanupTemp;

Expand Down
8 changes: 3 additions & 5 deletions src/libmain/common-args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@ MixCommonArgs::MixCommonArgs(const std::string & programName)
.shortName = 'v',
.description = "Increase the logging verbosity level.",
.category = loggingCategory,
.handler = {[]() {
verbosity = (Verbosity) std::min<std::underlying_type_t<Verbosity>>(verbosity + 1, lvlVomit);
}},
.handler = {[]() { ++verbosity; }},
});

addFlag({
.longName = "quiet",
.description = "Decrease the logging verbosity level.",
.category = loggingCategory,
.handler = {[]() { verbosity = verbosity > lvlError ? (Verbosity) (verbosity - 1) : lvlError; }},
.handler = {[]() { --verbosity; }},
});

addFlag({
.longName = "debug",
.description = "Set the logging verbosity level to 'debug'.",
.category = loggingCategory,
.handler = {[]() { verbosity = lvlDebug; }},
.handler = {[]() { verbosity = Verbosity::Debug; }},
});

addFlag({
Expand Down
4 changes: 2 additions & 2 deletions src/libmain/include/nix/main/shared.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void printGCWarning();
class Store;
struct MissingPaths;

void printMissing(ref<Store> store, const std::vector<DerivedPath> & paths, Verbosity lvl = lvlInfo);
void printMissing(ref<Store> store, const std::vector<DerivedPath> & paths, Verbosity lvl = Verbosity::Info);

void printMissing(ref<Store> store, const MissingPaths & missing, Verbosity lvl = lvlInfo);
void printMissing(ref<Store> store, const MissingPaths & missing, Verbosity lvl = Verbosity::Info);

std::string getArg(const std::string & opt, Strings::iterator & i, const Strings::iterator & end);

Expand Down
7 changes: 5 additions & 2 deletions src/libmain/progress-bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ class ProgressBar : public Logger
{
auto state(state_.lock());
if (state->suspensions == 0) {
log(lvlError, "nix::ProgressBar: resume() called without a matching preceding pause(). This is a bug.");
log(Verbosity::Error,
"nix::ProgressBar: resume() called without a matching preceding pause(). This is a bug.");
return;
} else {
state->suspensions--;
Expand Down Expand Up @@ -320,7 +321,9 @@ class ProgressBar : public Logger
if (type == resPostBuildLogLine) {
suffix = " (post)> ";
}
log(*state, lvlInfo, ANSI_FAINT + info.name.value_or("unnamed") + suffix + ANSI_NORMAL + lastLine);
log(*state,
Verbosity::Info,
ANSI_FAINT + info.name.value_or("unnamed") + suffix + ANSI_NORMAL + lastLine);
} else {
state->activities.erase(i->second);
info.lastLine = lastLine;
Expand Down
2 changes: 1 addition & 1 deletion src/libmain/shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void parseCmdLine(
void printVersion(const std::string & programName)
{
std::cout << fmt("%1% (Nix) %2%", programName, nixVersion) << std::endl;
if (verbosity > lvlInfo) {
if (verbosity > Verbosity::Info) {
Strings cfg;
#if NIX_USE_BOEHMGC
cfg.push_back("gc");
Expand Down
6 changes: 3 additions & 3 deletions src/libstore/aws-creds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class AwsCredentialProviderImpl : public AwsCredentialProvider
{
// Map Nix's verbosity to AWS CRT log level
Aws::Crt::LogLevel logLevel;
if (verbosity >= lvlVomit) {
if (verbosity >= Verbosity::Vomit) {
logLevel = Aws::Crt::LogLevel::Trace;
} else if (verbosity >= lvlDebug) {
} else if (verbosity >= Verbosity::Debug) {
logLevel = Aws::Crt::LogLevel::Debug;
} else if (verbosity >= lvlChatty) {
} else if (verbosity >= Verbosity::Chatty) {
logLevel = Aws::Crt::LogLevel::Info;
} else {
logLevel = Aws::Crt::LogLevel::Warn;
Expand Down
6 changes: 3 additions & 3 deletions src/libstore/binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(

auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
printMsg(
lvlTalkative,
Verbosity::Talkative,
"copying path '%1%' (%2% bytes, compressed %3$.1f%% in %4% ms) to binary cache",
printStorePath(narInfo->path),
info.narSize,
Expand Down Expand Up @@ -237,7 +237,7 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
if (fileExists(key))
return;

printMsg(lvlTalkative, "creating debuginfo link from '%s' to '%s'", key, target);
printMsg(Verbosity::Talkative, "creating debuginfo link from '%s' to '%s'", key, target);

upsertFile(key, json.dump(), "application/json");
};
Expand Down Expand Up @@ -451,7 +451,7 @@ void BinaryCacheStore::queryPathInfoUncached(
auto storePathS = printStorePath(storePath);
auto act = std::make_shared<Activity>(
*logger,
lvlTalkative,
Verbosity::Talkative,
actQueryPathInfo,
fmt("querying info about '%s' on '%s'", storePathS, uri),
Logger::Fields{storePathS, uri});
Expand Down
13 changes: 8 additions & 5 deletions src/libstore/build/derivation-building-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
#endif
act = std::make_unique<Activity>(
*logger,
lvlInfo,
Verbosity::Info,
actBuild,
msg,
Logger::Fields{
Expand Down Expand Up @@ -328,7 +328,10 @@ Goal::Co DerivationBuildingGoal::tryToBuild()

if (!outputLocks.lockPaths(lockFiles, "", false)) {
Activity act(
*logger, lvlWarn, actBuildWaiting, fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));
*logger,
Verbosity::Warn,
actBuildWaiting,
fmt("waiting for lock on %s", Magenta(showPaths(lockFiles))));

/* Wait then try locking again, repeat until success (returned
boolean is true). */
Expand Down Expand Up @@ -386,7 +389,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
if (!actLock)
actLock = std::make_unique<Activity>(
*logger,
lvlWarn,
Verbosity::Warn,
actBuildWaiting,
fmt("waiting for a machine to build '%s'", Magenta(worker.store.printStorePath(drvPath))));
outputLocks.unlock();
Expand Down Expand Up @@ -649,7 +652,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
if (!actLock)
actLock = std::make_unique<Activity>(
*logger,
lvlWarn,
Verbosity::Warn,
actBuildWaiting,
fmt("waiting for a free build user ID for '%s'", Magenta(worker.store.printStorePath(drvPath))));
co_await waitForAWhile();
Expand Down Expand Up @@ -738,7 +741,7 @@ static void runPostBuildHook(

Activity act(
logger,
lvlTalkative,
Verbosity::Talkative,
actPostBuildHook,
fmt("running post-build-hook '%s'", settings.postBuildHook),
Logger::Fields{store.printStorePath(drvPath)});
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/build/derivation-resolution-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Goal::Co DerivationResolutionGoal::resolveDerivation()
worker.store.printStorePath(pathResolved));
act = std::make_unique<Activity>(
*logger,
lvlInfo,
Verbosity::Info,
actBuildWaiting,
msg,
Logger::Fields{
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/build/substitution-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Goal::Co PathSubstitutionGoal::tryToRun(

worker.markContentsGood(storePath);

printMsg(lvlChatty, "substitution of path '%s' succeeded", worker.store.printStorePath(storePath));
printMsg(Verbosity::Chatty, "substitution of path '%s' succeeded", worker.store.printStorePath(storePath));

maintainRunningSubstitutions.reset();

Expand Down
Loading
Loading