aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/logging.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/logging.hh')
-rw-r--r--src/libutil/logging.hh30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index beb5e6b64..ba6f39ac9 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -1,20 +1,11 @@
#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,
actDownload = 101,
@@ -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)
{