diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-16T15·32+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-16T18·56+0200 |
commit | b4ed97e3a3116909fcaa79f5ce84487ed3838112 (patch) | |
tree | d8f1a29dc7a8049cfaa301ee2a04795afbf6c712 /src/libutil/logging.hh | |
parent | 23b8b7e096d3a2a784387a09f68115706b1e9552 (diff) |
nix optimise-store: Show how much space has been freed
Diffstat (limited to 'src/libutil/logging.hh')
-rw-r--r-- | src/libutil/logging.hh | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index bb89643d0a0b..e0b8c0855eae 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -24,6 +24,11 @@ typedef enum { actOptimiseStore = 106, } ActivityType; +typedef enum { + resFileLinked = 100, + resBuildLogLine = 101, +} ResultType; + typedef uint64_t ActivityId; class Logger @@ -49,9 +54,20 @@ public: virtual void progress(ActivityId act, uint64_t done = 0, uint64_t expected = 0, uint64_t running = 0, uint64_t failed = 0) { }; - virtual void progress(ActivityId act, const std::string & s) { }; - virtual void setExpected(ActivityId act, ActivityType type, uint64_t expected) { }; + + struct Field + { + // FIXME: use std::variant. + enum { tInt, tString } type; + uint64_t i = 0; + std::string s; + Field(const std::string & s) : type(tString), s(s) { } + Field(const char * s) : type(tString), s(s) { } + Field(const uint64_t & i) : type(tInt), i(i) { } + }; + + virtual void result(ActivityId act, ResultType type, const std::vector<Field> & fields) { }; }; struct Activity @@ -68,12 +84,17 @@ struct Activity void progress(uint64_t done = 0, uint64_t expected = 0, uint64_t running = 0, uint64_t failed = 0) const { logger.progress(id, done, expected, running, failed); } - void progress(const std::string & s) const - { logger.progress(id, s); } - void setExpected(ActivityType type2, uint64_t expected) const { logger.setExpected(id, type2, expected); } + template<typename... Args> + void result(ResultType type, const Args & ... args) + { + std::vector<Logger::Field> fields; + nop{(fields.emplace_back(Logger::Field(args)), 1)...}; + logger.result(id, type, fields); + } + friend class Logger; }; |