mirror of
https://github.com/NixOS/nix
synced 2025-06-30 19:57:59 +02:00
* Debug levels. Use `--verbose / -v LEVEL' to display only messages
up to the given verbosity levels. These currently are: lvlError = 0, lvlNormal = 5, lvlDebug = 10, lvlDebugMore = 15 although only lvlError and lvlDebug are actually used right now.
This commit is contained in:
parent
b75719b984
commit
1a7468a57a
8 changed files with 68 additions and 25 deletions
18
src/util.cc
18
src/util.cc
|
@ -130,13 +130,20 @@ void deletePath(string path)
|
|||
}
|
||||
|
||||
|
||||
Verbosity verbosity = lvlNormal;
|
||||
|
||||
static int nestingLevel = 0;
|
||||
|
||||
|
||||
Nest::Nest(bool nest)
|
||||
Nest::Nest(Verbosity level, const format & f)
|
||||
{
|
||||
this->nest = nest;
|
||||
if (nest) nestingLevel++;
|
||||
if (level > verbosity)
|
||||
nest = false;
|
||||
else {
|
||||
msg(level, f);
|
||||
nest = true;
|
||||
nestingLevel++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,8 +153,9 @@ Nest::~Nest()
|
|||
}
|
||||
|
||||
|
||||
void msg(const format & f)
|
||||
void msg(Verbosity level, const format & f)
|
||||
{
|
||||
if (level > verbosity) return;
|
||||
string spaces;
|
||||
for (int i = 0; i < nestingLevel; i++)
|
||||
spaces += "| ";
|
||||
|
@ -157,7 +165,7 @@ void msg(const format & f)
|
|||
|
||||
void debug(const format & f)
|
||||
{
|
||||
msg(format("debug: %1%") % f.str());
|
||||
msg(lvlDebug, format("debug: %1%") % f.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue