1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-13 05:56:03 +01:00

Use enum struct and drop prefixes

This does a few enums; the rest will be gotten in subsequent commits.
This commit is contained in:
John Ericson 2020-03-28 23:22:10 +00:00 committed by John Ericson
parent eb1911e277
commit 87b32bab05
57 changed files with 382 additions and 354 deletions

View file

@ -21,7 +21,7 @@ Logger * logger = makeDefaultLogger();
void Logger::warn(const std::string & msg)
{
log(lvlWarn, ANSI_YELLOW "warning:" ANSI_NORMAL " " + msg);
log(Verbosity::Warn, ANSI_YELLOW "warning:" ANSI_NORMAL " " + msg);
}
class SimpleLogger : public Logger
@ -45,10 +45,10 @@ public:
if (systemd) {
char c;
switch (lvl) {
case lvlError: c = '3'; break;
case lvlWarn: c = '4'; break;
case lvlInfo: c = '5'; break;
case lvlTalkative: case lvlChatty: c = '6'; break;
case Verbosity::Error: c = '3'; break;
case Verbosity::Warn: c = '4'; break;
case Verbosity::Info: c = '5'; break;
case Verbosity::Talkative: case Verbosity::Chatty: c = '6'; break;
default: c = '7';
}
prefix = std::string("<") + c + ">";
@ -66,7 +66,7 @@ public:
}
};
Verbosity verbosity = lvlInfo;
Verbosity verbosity = Verbosity::Info;
void warnOnce(bool & haveWarned, const FormatOrString & fs)
{
@ -123,7 +123,7 @@ struct JSONLogger : Logger
void write(const nlohmann::json & json)
{
prevLogger.log(lvlError, "@nix " + json.dump());
prevLogger.log(Verbosity::Error, "@nix " + json.dump());
}
void log(Verbosity lvl, const FormatOrString & fs) override
@ -198,7 +198,7 @@ bool handleJSONLogMessage(const std::string & msg,
if (action == "start") {
auto type = (ActivityType) json["type"];
if (trusted || type == actDownload)
if (trusted || type == ActivityType::Download)
activities.emplace(std::piecewise_construct,
std::forward_as_tuple(json["id"]),
std::forward_as_tuple(*logger, (Verbosity) json["level"], type,
@ -216,7 +216,7 @@ bool handleJSONLogMessage(const std::string & msg,
else if (action == "setPhase") {
std::string phase = json["phase"];
act.result(resSetPhase, phase);
act.result(ResultType::SetPhase, phase);
}
else if (action == "msg") {