diff options
Diffstat (limited to 'src/libnix/util.hh')
-rw-r--r-- | src/libnix/util.hh | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/libnix/util.hh b/src/libnix/util.hh index 02a9b7fcb885..e6b600eff8ce 100644 --- a/src/libnix/util.hh +++ b/src/libnix/util.hh @@ -101,12 +101,27 @@ class Nest private: bool nest; public: - Nest(Verbosity level, const format & f); + Nest(); ~Nest(); + void open(Verbosity level, const format & f); }; -void msg(Verbosity level, const format & f); -void debug(const format & f); /* short-hand for msg(lvlDebug, ...) */ +void printMsg_(Verbosity level, const format & f); + +#define startNest(varName, level, f) \ + Nest varName; \ + if (level <= verbosity) { \ + varName.open(level, (f)); \ + } + +#define printMsg(level, f) \ + do { \ + if (level <= verbosity) { \ + printMsg_(level, (f)); \ + } \ + } while (0) + +#define debug(f) printMsg(lvlDebug, f) /* Wrappers arount read()/write() that read/write exactly the |