aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/logging.hh
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-04-17 15:07:44 -0600
committerBen Burdette <bburdette@gmail.com>2020-04-17 15:07:44 -0600
commit3d5b1032a193419cfa7406f0e42a7621994d70af (patch)
treeee5c26b21dbed957bc5b9fdbbb4667e10d4bddf2 /src/libutil/logging.hh
parent12814806efca65a73aebf8d3109eb2fbf880e2b8 (diff)
logError, logWarning; Logger functions; switch to Verbosity enum
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)
{