mirror of
https://github.com/NixOS/nix
synced 2025-06-27 00:11:17 +02:00
logError, logWarning; Logger functions; switch to Verbosity enum
This commit is contained in:
parent
12814806ef
commit
3d5b1032a1
7 changed files with 128 additions and 66 deletions
|
@ -1,19 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.hh"
|
||||
#include "error.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
typedef enum {
|
||||
lvlError = 0,
|
||||
lvlWarn,
|
||||
lvlInfo,
|
||||
lvlTalkative,
|
||||
lvlChatty,
|
||||
lvlDebug,
|
||||
lvlVomit
|
||||
} Verbosity;
|
||||
|
||||
typedef enum {
|
||||
actUnknown = 0,
|
||||
actCopyPath = 100,
|
||||
|
@ -70,6 +61,13 @@ public:
|
|||
log(lvlInfo, fs);
|
||||
}
|
||||
|
||||
virtual void logEI(const ErrorInfo &ei) = 0;
|
||||
|
||||
void logEI(Verbosity lvl, ErrorInfo ei) {
|
||||
ei.level = lvl;
|
||||
logEI(ei);
|
||||
}
|
||||
|
||||
virtual void warn(const std::string & msg);
|
||||
|
||||
virtual void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
||||
|
@ -157,6 +155,18 @@ extern Verbosity verbosity; /* suppress msgs > this */
|
|||
#define debug(args...) printMsg(lvlDebug, args)
|
||||
#define vomit(args...) printMsg(lvlVomit, args)
|
||||
|
||||
#define logErrorInfo(level, errorInfo...) \
|
||||
do { \
|
||||
if (level <= nix::verbosity) { \
|
||||
logger->logEI(level, errorInfo); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define logError(errorInfo...) logErrorInfo(lvlError, errorInfo)
|
||||
#define logWarning(errorInfo...) logErrorInfo(lvlWarn, errorInfo)
|
||||
|
||||
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(const std::string & fs, const Args & ... args)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue