diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-28 19:13:24 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-28 19:13:24 +0200 |
commit | 2cc345b95f19334e7050c7203a5f6823af24344f (patch) | |
tree | 0bb381ffa64ceb59fac0ab6416e5699854c0c028 /src/libutil | |
parent | cfc813239128fc69a9228b39b5c0abb7e7a67b11 (diff) |
Give activities a verbosity level again
And print them (separately from the progress bar) given sufficient -v
flags.
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/logging.cc | 11 | ||||
-rw-r--r-- | src/libutil/logging.hh | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc index b103b902e..e38a46053 100644 --- a/src/libutil/logging.cc +++ b/src/libutil/logging.cc @@ -45,6 +45,13 @@ public: writeToStderr(prefix + (tty ? fs.s : filterANSIEscapes(fs.s)) + "\n"); } + + void startActivity(ActivityId act, Verbosity lvl, ActivityType type, + const std::string & s, const Fields & fields, ActivityId parent) + { + if (lvl <= verbosity && !s.empty()) + log(lvl, s + "..."); + } }; Verbosity verbosity = lvlInfo; @@ -76,11 +83,11 @@ Logger * makeDefaultLogger() std::atomic<uint64_t> nextId{(uint64_t) getpid() << 32}; -Activity::Activity(Logger & logger, ActivityType type, +Activity::Activity(Logger & logger, Verbosity lvl, ActivityType type, const std::string & s, const Logger::Fields & fields, ActivityId parent) : logger(logger), id(nextId++) { - logger.startActivity(id, type, s, fields, parent); + logger.startActivity(id, lvl, type, s, fields, parent); } } diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index e3e7c8e6f..84fffa820 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -68,7 +68,7 @@ public: virtual void warn(const std::string & msg); - virtual void startActivity(ActivityId act, ActivityType type, + virtual void startActivity(ActivityId act, Verbosity lvl, ActivityType type, const std::string & s, const Fields & fields, ActivityId parent) { }; virtual void stopActivity(ActivityId act) { }; @@ -84,9 +84,13 @@ struct Activity const ActivityId id; - Activity(Logger & logger, ActivityType type, const std::string & s = "", + Activity(Logger & logger, Verbosity lvl, ActivityType type, const std::string & s = "", const Logger::Fields & fields = {}, ActivityId parent = curActivity); + Activity(Logger & logger, ActivityType type, + const Logger::Fields & fields = {}, ActivityId parent = curActivity) + : Activity(logger, lvlError, type, "", fields, parent) { }; + Activity(const Activity & act) = delete; ~Activity() |