libutil, cli: remove Logger::warn

only use the free function instead, so we can turn that into a macro.

Change-Id: I0319e9f7bdebb96f6159053e8b7b7a82559c9b33
This commit is contained in:
eldritch horrors
2025-08-25 21:00:15 +00:00
parent f40a60f46a
commit 03ab20e191
3 changed files with 16 additions and 12 deletions
-5
View File
@@ -21,11 +21,6 @@ static GlobalConfig::Register rLoggerSettings(&loggerSettings);
Logger * logger = makeSimpleLogger(true);
void Logger::warn(const std::string & msg)
{
log(lvlWarn, ANSI_WARNING "warning:" ANSI_NORMAL " " + msg);
}
void Logger::writeToStdout(std::string_view s)
{
writeFull(
+4 -4
View File
@@ -140,8 +140,6 @@ public:
logEI(ei);
}
virtual void warn(const std::string & msg);
virtual void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
const std::string & s, const Fields & fields, ActivityId parent) { };
@@ -279,9 +277,11 @@ extern Verbosity verbosity;
* if verbosity >= lvlWarn, print a message with a yellow 'warning:' prefix.
*/
template<typename... Args>
inline void warn(const std::string & fs, const Args & ... args)
inline void warn(const std::string & fs, const Args &... args)
{
logger->warn(HintFmt(fs, args...).str());
logger->log(
lvlWarn, fmt(ANSI_WARNING "warning:" ANSI_NORMAL " %1%", HintFmt(fs, args...).str())
);
}
void writeLogsToStderr(std::string_view s);
+12 -3
View File
@@ -1340,7 +1340,10 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
if (!json)
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--all-systems' to show)", headerPrefix));
else {
logger->warn(fmt("%s omitted (use '--all-systems' to show)", concatStringsSep(".", attrPath)));
warn(
"%s omitted (use '--all-systems' to show)",
concatStringsSep(".", attrPath)
);
}
} else {
if (visitor.isDerivation(*state))
@@ -1364,13 +1367,19 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
if (!json)
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix));
else {
logger->warn(fmt("%s omitted (use '--legacy' to show)", concatStringsSep(".", attrPath)));
warn(
"%s omitted (use '--legacy' to show)",
concatStringsSep(".", attrPath)
);
}
} else if (!showAllSystems && attrPath[1] != localSystem) {
if (!json)
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--all-systems' to show)", headerPrefix));
else {
logger->warn(fmt("%s omitted (use '--all-systems' to show)", concatStringsSep(".", attrPath)));
warn(
"%s omitted (use '--all-systems' to show)",
concatStringsSep(".", attrPath)
);
}
} else {
if (visitor.isDerivation(*state))