mirror of
https://github.com/NixOS/nix
synced 2025-06-26 15:51:15 +02:00
Some notational convenience for formatting strings
We can now write throw Error("file '%s' not found", path); instead of throw Error(format("file '%s' not found") % path); and similarly printError("file '%s' not found", path); instead of printMsg(lvlError, format("file '%s' not found") % path);
This commit is contained in:
parent
3f8e620b19
commit
4036185cb4
6 changed files with 81 additions and 22 deletions
|
@ -66,14 +66,19 @@ Logger * makeDefaultLogger();
|
|||
|
||||
extern Verbosity verbosity; /* suppress msgs > this */
|
||||
|
||||
#define printMsg(level, f) \
|
||||
/* Print a message if the current log level is at least the specified
|
||||
level. Note that this has to be implemented as a macro to ensure
|
||||
that the arguments are evaluated lazily. */
|
||||
#define printMsg(level, args...) \
|
||||
do { \
|
||||
if (level <= nix::verbosity) { \
|
||||
logger->log(level, (f)); \
|
||||
logger->log(level, fmt(args)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define debug(f) printMsg(lvlDebug, f)
|
||||
#define printError(args...) printMsg(lvlError, args)
|
||||
#define printInfo(args...) printMsg(lvlInfo, args)
|
||||
#define debug(args...) printMsg(lvlDebug, args)
|
||||
|
||||
void warnOnce(bool & haveWarned, const FormatOrString & fs);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue