mirror of
https://github.com/NixOS/nix
synced 2025-06-29 23:13:14 +02: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:
parent
eb1911e277
commit
87b32bab05
57 changed files with 382 additions and 354 deletions
|
@ -4,41 +4,41 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
typedef enum {
|
||||
lvlError = 0,
|
||||
lvlWarn,
|
||||
lvlInfo,
|
||||
lvlTalkative,
|
||||
lvlChatty,
|
||||
lvlDebug,
|
||||
lvlVomit
|
||||
} Verbosity;
|
||||
enum struct Verbosity : uint64_t {
|
||||
Error = 0,
|
||||
Warn,
|
||||
Info,
|
||||
Talkative,
|
||||
Chatty,
|
||||
Debug,
|
||||
Vomit,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
actUnknown = 0,
|
||||
actCopyPath = 100,
|
||||
actDownload = 101,
|
||||
actRealise = 102,
|
||||
actCopyPaths = 103,
|
||||
actBuilds = 104,
|
||||
actBuild = 105,
|
||||
actOptimiseStore = 106,
|
||||
actVerifyPaths = 107,
|
||||
actSubstitute = 108,
|
||||
actQueryPathInfo = 109,
|
||||
actPostBuildHook = 110,
|
||||
} ActivityType;
|
||||
enum struct ActivityType : uint64_t {
|
||||
Unknown = 0,
|
||||
CopyPath = 100,
|
||||
Download = 101,
|
||||
Realise = 102,
|
||||
CopyPaths = 103,
|
||||
Builds = 104,
|
||||
Build = 105,
|
||||
OptimiseStore = 106,
|
||||
VerifyPaths = 107,
|
||||
Substitute = 108,
|
||||
QueryPathInfo = 109,
|
||||
PostBuildHook = 110,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
resFileLinked = 100,
|
||||
resBuildLogLine = 101,
|
||||
resUntrustedPath = 102,
|
||||
resCorruptedPath = 103,
|
||||
resSetPhase = 104,
|
||||
resProgress = 105,
|
||||
resSetExpected = 106,
|
||||
resPostBuildLogLine = 107,
|
||||
} ResultType;
|
||||
enum struct ResultType : uint64_t {
|
||||
FileLinked = 100,
|
||||
BuildLogLine = 101,
|
||||
UntrustedPath = 102,
|
||||
CorruptedPath = 103,
|
||||
SetPhase = 104,
|
||||
Progress = 105,
|
||||
SetExpected = 106,
|
||||
PostBuildLogLine = 107,
|
||||
};
|
||||
|
||||
typedef uint64_t ActivityId;
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
void log(const FormatOrString & fs)
|
||||
{
|
||||
log(lvlInfo, fs);
|
||||
log(Verbosity::Info, fs);
|
||||
}
|
||||
|
||||
virtual void warn(const std::string & msg);
|
||||
|
@ -94,17 +94,17 @@ struct Activity
|
|||
|
||||
Activity(Logger & logger, ActivityType type,
|
||||
const Logger::Fields & fields = {}, ActivityId parent = getCurActivity())
|
||||
: Activity(logger, lvlError, type, "", fields, parent) { };
|
||||
: Activity(logger, Verbosity::Error, type, "", fields, parent) { };
|
||||
|
||||
Activity(const Activity & act) = delete;
|
||||
|
||||
~Activity();
|
||||
|
||||
void progress(uint64_t done = 0, uint64_t expected = 0, uint64_t running = 0, uint64_t failed = 0) const
|
||||
{ result(resProgress, done, expected, running, failed); }
|
||||
{ result(ResultType::Progress, done, expected, running, failed); }
|
||||
|
||||
void setExpected(ActivityType type2, uint64_t expected) const
|
||||
{ result(resSetExpected, type2, expected); }
|
||||
{ result(ResultType::SetExpected, (uint64_t)type2, expected); }
|
||||
|
||||
template<typename... Args>
|
||||
void result(ResultType type, const Args & ... args) const
|
||||
|
@ -151,11 +151,11 @@ extern Verbosity verbosity; /* suppress msgs > this */
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define printError(args...) printMsg(lvlError, args)
|
||||
#define printInfo(args...) printMsg(lvlInfo, args)
|
||||
#define printTalkative(args...) printMsg(lvlTalkative, args)
|
||||
#define debug(args...) printMsg(lvlDebug, args)
|
||||
#define vomit(args...) printMsg(lvlVomit, args)
|
||||
#define printError(args...) printMsg(Verbosity::Error, args)
|
||||
#define printInfo(args...) printMsg(Verbosity::Info, args)
|
||||
#define printTalkative(args...) printMsg(Verbosity::Talkative, args)
|
||||
#define debug(args...) printMsg(Verbosity::Debug, args)
|
||||
#define vomit(args...) printMsg(Verbosity::Vomit, args)
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(const std::string & fs, const Args & ... args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue