treewide: colorize logs by default
printTaggedWarning already colorized its messages. we can do the same for most other log messages. Change-Id: Idcd31bbf4f8d0d703395b0d2b7b9bc33264d969f
This commit is contained in:
@@ -158,7 +158,8 @@ static void printSelectionFailureMessage(
|
||||
.str();
|
||||
}
|
||||
|
||||
auto error = HintFmt(
|
||||
printMsg(
|
||||
level,
|
||||
"Failed to find a machine for remote build!\n"
|
||||
"derivation: %s\n"
|
||||
"required (system, features): (%s, [%s])\n"
|
||||
@@ -170,8 +171,6 @@ static void printSelectionFailureMessage(
|
||||
machines.size(),
|
||||
Uncolored(machinesFormatted)
|
||||
);
|
||||
|
||||
printMsg(level, "%1%", error.str());
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -103,7 +103,7 @@ static int main_nix_collect_garbage(AsyncIoRoot & aio, std::string programName,
|
||||
if (dryRun) {
|
||||
// Only print results for dry run; when !dryRun, paths will be printed as they're deleted.
|
||||
for (auto & i : results.paths) {
|
||||
printInfo("%s", i);
|
||||
printInfo("%s", Uncolored(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -686,8 +686,12 @@ static void upgradeDerivations(Globals & globals,
|
||||
{
|
||||
const char * action = compareVersions(drvName.version, bestVersion) <= 0
|
||||
? "upgrading" : "downgrading";
|
||||
printInfo("%1% '%2%' to '%3%'",
|
||||
action, i.queryName(*state), bestElem->queryName(*state));
|
||||
printInfo(
|
||||
"%1% '%2%' to '%3%'",
|
||||
Uncolored(action),
|
||||
i.queryName(*state),
|
||||
bestElem->queryName(*state)
|
||||
);
|
||||
newElems.push_back(*bestElem);
|
||||
} else newElems.push_back(i);
|
||||
|
||||
|
||||
+6
-6
@@ -290,7 +290,7 @@ ReplExitStatus NixRepl::mainLoop()
|
||||
if (evaluator.debug && evaluator.debug->inDebugger) {
|
||||
debuggerNotice = " debugger";
|
||||
}
|
||||
notice("Lix %1%%2%\nType :? for help.", nixVersion, debuggerNotice);
|
||||
notice("Lix %1%%2%\nType :? for help.", Uncolored(nixVersion), debuggerNotice);
|
||||
}
|
||||
|
||||
isFirstRepl = false;
|
||||
@@ -337,14 +337,14 @@ ReplExitStatus NixRepl::mainLoop()
|
||||
// input without clearing the input so far.
|
||||
continue;
|
||||
} else {
|
||||
printMsg(lvlError, "%1%", e.msg());
|
||||
printMsg(lvlError, "%1%", Uncolored(e.msg()));
|
||||
}
|
||||
} catch (EvalError & e) {
|
||||
printMsg(lvlError, "%1%", e.msg());
|
||||
printMsg(lvlError, "%1%", Uncolored(e.msg()));
|
||||
} catch (Error & e) {
|
||||
printMsg(lvlError, "%1%", e.msg());
|
||||
printMsg(lvlError, "%1%", Uncolored(e.msg()));
|
||||
} catch (Interrupted & e) {
|
||||
printMsg(lvlError, "%1%", e.msg());
|
||||
printMsg(lvlError, "%1%", Uncolored(e.msg()));
|
||||
}
|
||||
|
||||
// We handled the current input fully, so we should clear it
|
||||
@@ -960,7 +960,7 @@ void NixRepl::loadReplOverlays()
|
||||
return;
|
||||
}
|
||||
|
||||
notice("Loading '%1%'...", Magenta("repl-overlays"));
|
||||
notice("Loading '%1%'...", "repl-overlays");
|
||||
auto replInitFilesFunction = getReplOverlaysEvalFunction();
|
||||
|
||||
Value &newAttrs(*evaluator.mem.allocValue());
|
||||
|
||||
+1
-1
@@ -749,7 +749,7 @@ void DebugState::onEvalError(
|
||||
|
||||
if (error)
|
||||
{
|
||||
printError("%s\n", error->what());
|
||||
printError("%s\n", Uncolored(error->what()));
|
||||
|
||||
if (trylevel > 0 && error->info().level != lvlInfo) {
|
||||
if (evalSettings.ignoreExceptionsDuringTry) {
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace nix {
|
||||
FunctionCallTrace::FunctionCallTrace(const Pos & pos) : pos(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 entered %1% at %2%", pos, ns.count());
|
||||
printMsg(lvlInfo, "function-trace entered %1% at %2%", Uncolored(pos), Uncolored(ns.count()));
|
||||
}
|
||||
|
||||
FunctionCallTrace::~FunctionCallTrace() {
|
||||
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%", pos, ns.count());
|
||||
printMsg(lvlInfo, "function-trace exited %1% at %2%", Uncolored(pos), Uncolored(ns.count()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -695,9 +695,9 @@ static void prim_trace(EvalState & state, Value * * args, Value & v)
|
||||
{
|
||||
state.forceValue(*args[0], noPos);
|
||||
if (args[0]->type() == nString)
|
||||
printError("trace: %1%", args[0]->str());
|
||||
printError("trace: %1%", Uncolored(args[0]->str()));
|
||||
else
|
||||
printError("trace: %1%", ValuePrinter(state, *args[0]));
|
||||
printError("trace: %1%", Uncolored(ValuePrinter(state, *args[0])));
|
||||
if (auto last = evalSettings.builtinsTraceDebugger && state.ctx.debug
|
||||
? state.ctx.debug->traces().next()
|
||||
: std::nullopt)
|
||||
|
||||
@@ -90,7 +90,7 @@ try {
|
||||
data = TRY_AWAIT(content->drain());
|
||||
} catch (FileTransferError & e) {
|
||||
if (cached) {
|
||||
printTaggedWarning("%s; using cached version", e.msg());
|
||||
printTaggedWarning("%s; using cached version", Uncolored(e.msg()));
|
||||
co_return useCached();
|
||||
} else
|
||||
throw;
|
||||
|
||||
@@ -74,7 +74,7 @@ try {
|
||||
auto sorted = TRY_AWAIT(store->topoSortPaths(willBuild));
|
||||
reverse(sorted.begin(), sorted.end());
|
||||
for (auto & i : sorted)
|
||||
printMsg(lvl, " %s", store->printStorePath(i));
|
||||
printMsg(lvl, " %s", Uncolored(store->printStorePath(i)));
|
||||
}
|
||||
|
||||
if (!willSubstitute.empty()) {
|
||||
@@ -101,14 +101,14 @@ try {
|
||||
return lhs->name() < rhs->name();
|
||||
});
|
||||
for (auto p : willSubstituteSorted)
|
||||
printMsg(lvl, " %s", store->printStorePath(*p));
|
||||
printMsg(lvl, " %s", Uncolored(store->printStorePath(*p)));
|
||||
}
|
||||
|
||||
if (!unknown.empty()) {
|
||||
printMsg(lvl, "don't know how to build these paths%s:",
|
||||
(settings.readOnlyMode ? " (may be caused by read-only store access)" : ""));
|
||||
for (auto & i : unknown)
|
||||
printMsg(lvl, " %s", store->printStorePath(i));
|
||||
printMsg(lvl, " %s", Uncolored(store->printStorePath(i)));
|
||||
}
|
||||
|
||||
co_return result::success();
|
||||
@@ -331,7 +331,7 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
|
||||
if (onlyForSubcommands)
|
||||
printError("'%1%' is reserved for external subcommands, is your subcommand available in the PATH?", programName);
|
||||
else
|
||||
printError("Try '%1% --help' for more information.", programName);
|
||||
printError("Try '%1%' for more information.", programName + " --help");
|
||||
return 1;
|
||||
} catch (BaseError & e) {
|
||||
logError(e.info());
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace nix {
|
||||
|
||||
void Goal::trace(std::string_view s)
|
||||
{
|
||||
debug("%1%: %2%", name, s);
|
||||
debug("%1%: %2%", Uncolored(name), Uncolored(s));
|
||||
}
|
||||
|
||||
kj::Promise<void> Goal::waitForAWhile()
|
||||
|
||||
@@ -98,7 +98,7 @@ void handleDiffHook(
|
||||
statusToString(diffRes.first));
|
||||
|
||||
if (diffRes.second != "") {
|
||||
printError("%1%", chomp(diffRes.second));
|
||||
printError("%1%", Uncolored(chomp(diffRes.second)));
|
||||
}
|
||||
} catch (Error & error) {
|
||||
ErrorInfo ei = error.info();
|
||||
@@ -845,7 +845,7 @@ try {
|
||||
ex.addTrace({}, "while setting up the build environment");
|
||||
throw ex;
|
||||
}
|
||||
debug("sandbox setup: %1%", msg);
|
||||
debug("sandbox setup: %1%", Uncolored(msg));
|
||||
msgs.push_back(std::move(msg));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ Goal::WorkResult PathSubstitutionGoal::done(
|
||||
{
|
||||
BuildResult buildResult{.status = status};
|
||||
if (errorMsg) {
|
||||
debug("%1%", *errorMsg);
|
||||
debug("%1%", Uncolored(*errorMsg));
|
||||
buildResult.errorMsg = *errorMsg;
|
||||
}
|
||||
return WorkResult{result, std::move(buildResult)};
|
||||
@@ -263,7 +263,7 @@ try {
|
||||
thr.get();
|
||||
break;
|
||||
} catch (std::exception & e) { // NOLINT(lix-foreign-exceptions)
|
||||
printError("%1%", e.what());
|
||||
printError("%1%", Uncolored(e.what()));
|
||||
|
||||
/* Cause the parent build to fail unless --fallback is given,
|
||||
or the substitute has disappeared. The latter case behaves
|
||||
|
||||
@@ -75,7 +75,7 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData,
|
||||
);
|
||||
return;
|
||||
} catch (Error & e) {
|
||||
debug("%1%", e.what());
|
||||
debug("%1%", Uncolored(e.what()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,15 +1039,19 @@ struct curlFileTransfer : public FileTransfer
|
||||
if (totalReceived) {
|
||||
printTaggedWarning(
|
||||
"%s; retrying from offset %d in %d ms (attempt %d/%d)",
|
||||
context,
|
||||
Uncolored(context),
|
||||
totalReceived,
|
||||
waitTime,
|
||||
attempt,
|
||||
tries
|
||||
Uncolored(attempt),
|
||||
Uncolored(tries)
|
||||
);
|
||||
} else {
|
||||
printTaggedWarning(
|
||||
"%s; retrying in %d ms (attempt %d/%d)", context, waitTime, attempt, tries
|
||||
"%s; retrying in %d ms (attempt %d/%d)",
|
||||
Uncolored(context),
|
||||
waitTime,
|
||||
Uncolored(attempt),
|
||||
Uncolored(tries)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -830,7 +830,7 @@ try {
|
||||
if (!kept.empty()) {
|
||||
printTalkative("Paths not deleted because they are still referenced by GC roots:");
|
||||
for (auto &path: kept) {
|
||||
printTalkative("%1%", path);
|
||||
printTalkative("%1%", Uncolored(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ PathLock::lockImpl(const Path & path, std::string_view waitMsg, bool wait, Never
|
||||
if (!tryLockFile(fd.get(), ltWrite)) {
|
||||
if (wait) {
|
||||
if (waitMsg != "") {
|
||||
printError("%1%", waitMsg);
|
||||
printError("%1%", Uncolored(waitMsg));
|
||||
}
|
||||
lockFile(fd.get(), ltWrite);
|
||||
} else {
|
||||
@@ -258,7 +258,7 @@ FdLock::FdLock(AutoCloseFD & fd, LockType lockType, DontWait)
|
||||
FdLock::FdLock(AutoCloseFD & fd, LockType lockType, std::string_view waitMsg, NeverAsync)
|
||||
{
|
||||
if (!tryLockFile(fd.get(), lockType)) {
|
||||
printInfo("%s", waitMsg);
|
||||
printInfo("%s", Uncolored(waitMsg));
|
||||
lockFile(fd.get(), lockType);
|
||||
this->fd.reset(&fd);
|
||||
}
|
||||
@@ -268,7 +268,7 @@ kj::Promise<Result<FdLock>>
|
||||
FdLock::lockAsync(AutoCloseFD & fd, LockType lockType, std::string_view waitMsg)
|
||||
try {
|
||||
if (!tryLockFile(fd.get(), lockType)) {
|
||||
printInfo("%s", waitMsg);
|
||||
printInfo("%s", Uncolored(waitMsg));
|
||||
TRY_AWAIT(lockFileAsyncInner(fd.get(), lockType));
|
||||
}
|
||||
co_return FdLock{fd};
|
||||
|
||||
@@ -792,7 +792,7 @@ try {
|
||||
}
|
||||
|
||||
else if (msg == STDERR_NEXT)
|
||||
printError("%1%", chomp(TRY_AWAIT(readString(from))));
|
||||
printError("%1%", Uncolored(chomp(TRY_AWAIT(readString(from)))));
|
||||
|
||||
else if (msg == STDERR_START_ACTIVITY) {
|
||||
auto act = TRY_AWAIT(readNum<ActivityId>(from));
|
||||
|
||||
@@ -62,16 +62,12 @@ void setStackSize(rlim_t stackSize)
|
||||
limit.rlim_cur = std::min(stackSize, limit.rlim_max);
|
||||
if (setrlimit(RLIMIT_STACK, &limit) != 0) {
|
||||
printError(
|
||||
"%1%",
|
||||
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()
|
||||
"Failed to increase stack size from %1% to %2% (maximum allowed stack size: %3%): "
|
||||
"%4%",
|
||||
savedStackSize,
|
||||
stackSize,
|
||||
limit.rlim_max,
|
||||
std::strerror(errno)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ public:
|
||||
{
|
||||
if (type == resBuildLogLine && printBuildLogs) {
|
||||
auto lastLine = fields[0].s;
|
||||
printError("%1%", lastLine);
|
||||
printError("%1%", Uncolored(lastLine));
|
||||
}
|
||||
else if (type == resPostBuildLogLine) {
|
||||
auto lastLine = fields[0].s;
|
||||
printError("post-build-hook: %1%", lastLine);
|
||||
printError("post-build-hook: %1%", Uncolored(lastLine));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -262,7 +262,7 @@ extern Verbosity verbosity;
|
||||
auto _lix_logger_print_lvl = level; \
|
||||
const char * _lix_format = []<size_t N>(const char(&_lix_fs)[N]) { return _lix_fs; }(fs); \
|
||||
if (_lix_logger_print_lvl <= ::nix::verbosity) { \
|
||||
loggerParam->log(_lix_logger_print_lvl, ::nix::fmt(_lix_format, ##args)); \
|
||||
loggerParam->log(_lix_logger_print_lvl, ::nix::HintFmt(_lix_format, ##args).str()); \
|
||||
} \
|
||||
} while (0)
|
||||
#define printMsg(level, fs, args...) printMsgUsing(::nix::logger, level, fs, ##args)
|
||||
@@ -276,7 +276,7 @@ extern Verbosity verbosity;
|
||||
#define vomit(fs, args...) printMsg(::nix::lvlVomit, fs, ##args)
|
||||
|
||||
#define printTaggedWarning(fs, args...) \
|
||||
printWarning("%1%", ::nix::HintFmt(ANSI_WARNING "warning:" ANSI_NORMAL " " fs, ##args).str())
|
||||
printWarning(ANSI_WARNING "warning:" ANSI_NORMAL " " fs, ##args)
|
||||
|
||||
void writeLogsToStderr(std::string_view s);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ void restoreMountNamespace()
|
||||
if (chdir(savedCwd.c_str()) == -1)
|
||||
throw SysError("restoring cwd");
|
||||
} catch (Error & e) {
|
||||
debug("%1%", e.msg());
|
||||
debug("%1%", Uncolored(e.msg()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+1
-1
@@ -406,7 +406,7 @@ static void daemonInstance(AsyncIoRoot & aio, std::optional<TrustedFlag> forceTr
|
||||
|
||||
printInfo(
|
||||
"%1% is %2% (%3%%4%)",
|
||||
peer.pidKnown ? fmt("remote pid %s", peer.pid) : "remote with unknown pid",
|
||||
Uncolored(peer.pidKnown ? fmt("remote pid %s", peer.pid) : "remote with unknown pid"),
|
||||
peer.uidKnown ? fmt("user %s", user) : "unknown user",
|
||||
trusted ? "trusted" : "untrusted",
|
||||
forceTrustClientOpt ? " by override" : ""
|
||||
|
||||
+3
-3
@@ -25,17 +25,17 @@ std::string formatProtocol(unsigned int proto)
|
||||
}
|
||||
|
||||
bool checkPass(const std::string & msg) {
|
||||
notice(ANSI_GREEN "[PASS]" ANSI_NORMAL " %1%", msg);
|
||||
notice(ANSI_GREEN "[PASS] " ANSI_NORMAL "%1%", Uncolored(msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool checkFail(const std::string & msg) {
|
||||
notice(ANSI_RED "[FAIL]" ANSI_NORMAL " %1%", msg);
|
||||
notice(ANSI_RED "[FAIL] " ANSI_NORMAL "%1%", Uncolored(msg));
|
||||
return false;
|
||||
}
|
||||
|
||||
void checkInfo(const std::string & msg) {
|
||||
notice(ANSI_BLUE "[INFO]" ANSI_NORMAL " %1%", msg);
|
||||
notice(ANSI_BLUE "[INFO] " ANSI_NORMAL "%1%", Uncolored(msg));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -956,9 +956,9 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||
if (welcomeText) {
|
||||
notice(
|
||||
"\n%1%",
|
||||
renderMarkdownToTerminal(
|
||||
Uncolored(renderMarkdownToTerminal(
|
||||
welcomeText->getString(*evalState), StandardOutputStream::Stderr
|
||||
)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ struct Proc {
|
||||
JSON err;
|
||||
auto msg = e.msg();
|
||||
err["error"] = nix::filterANSIEscapes(msg, true);
|
||||
printError("%1%", msg);
|
||||
printError("%1%", Uncolored(msg));
|
||||
if (tryWriteLine(to->get(), err.dump()) < 0) {
|
||||
return; // main process died
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user