diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-25T15·49+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-25T15·49+0200 |
commit | c137c0a5ebc0d58c53f86986ab66967ac8629cbe (patch) | |
tree | 38e01bef5549985449a4c911c1444758d585335f /src/libutil/logging.hh | |
parent | f194629f96d4bdbded897e7e88ac0d03211c959d (diff) |
Allow activities to be nested
In particular, this allows more relevant activities ("substituting X") to supersede inferior ones ("downloading X").
Diffstat (limited to 'src/libutil/logging.hh')
-rw-r--r-- | src/libutil/logging.hh | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index 567af361e8e9..9427f268267a 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -23,6 +23,7 @@ typedef enum { actBuild = 105, actOptimiseStore = 106, actVerifyPaths = 107, + actSubstitute = 108, } ActivityType; typedef enum { @@ -65,7 +66,7 @@ public: virtual void warn(const std::string & msg); virtual void startActivity(ActivityId act, ActivityType type, - const std::string & s, const Fields & fields) { }; + const std::string & s, const Fields & fields, ActivityId parent) { }; virtual void stopActivity(ActivityId act) { }; @@ -76,6 +77,8 @@ public: virtual void result(ActivityId act, ResultType type, const Fields & fields) { }; }; +extern thread_local ActivityId curActivity; + struct Activity { Logger & logger; @@ -83,7 +86,7 @@ struct Activity const ActivityId id; Activity(Logger & logger, ActivityType type, const std::string & s = "", - const Logger::Fields & fields = {}); + const Logger::Fields & fields = {}, ActivityId parent = curActivity); Activity(const Activity & act) = delete; @@ -107,6 +110,13 @@ struct Activity friend class Logger; }; +struct PushActivity +{ + const ActivityId prevAct; + PushActivity(ActivityId act) : prevAct(curActivity) { curActivity = act; } + ~PushActivity() { curActivity = prevAct; } +}; + extern Logger * logger; Logger * makeDefaultLogger(); |