diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-14T17·00+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-16T18·56+0200 |
commit | b29b6feaba715432490e275a025b3361a021a99b (patch) | |
tree | 5b7092b0183a135f807fa85539bbf5ea42acf615 /src/libutil | |
parent | c5e4404580164d3edd043e79cf72bac5bdaecb42 (diff) |
nix copy: Improve progress indicator
It now shows the amount of data copied: [8/1038 copied, 160.4/1590.9 MiB copied] copying path '...'
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/logging.cc | 2 | ||||
-rw-r--r-- | src/libutil/logging.hh | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc index c11271e63007..321c90712917 100644 --- a/src/libutil/logging.cc +++ b/src/libutil/logging.cc @@ -83,7 +83,7 @@ Activity::Activity() : id(nextId++) { }; Activity::Activity(ActivityType type, std::string msg) : Activity() { - logger->event(evStartActivity, id, msg); + logger->event(evStartActivity, id, type, msg); } Activity::~Activity() diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index aa407f60bb65..6a4a36171560 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -14,6 +14,7 @@ typedef enum { } Verbosity; typedef enum { + actUnknown = 0, actCopyPath = 100, } ActivityType; @@ -28,7 +29,8 @@ public: Activity(ActivityType type, std::string msg = ""); ~Activity(); - //void progress(...); + template<typename... Args> + void progress(const Args & ... args); }; typedef enum { @@ -49,6 +51,8 @@ typedef enum { evStartActivity = 1000, evStopActivity = 1001, + evProgress = 1002, + evSetExpected = 1003, } EventType; @@ -149,4 +153,14 @@ void warnOnce(bool & haveWarned, const FormatOrString & fs); void writeToStderr(const string & s); +template<typename... Args> +void Activity::progress(const Args & ... args) +{ + Event ev; + ev.type = evProgress; + ev.fields.emplace_back(id); + nop{(ev.fields.emplace_back(Event::Field(args)), 1)...}; + logger->event(ev); +} + } |