aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/logging.hh
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-06-04 11:53:19 -0600
committerBen Burdette <bburdette@gmail.com>2020-06-04 11:53:19 -0600
commit94427ffee3493077206f960e3cda9bbb659583be (patch)
tree5ab98795998d949621fa7568338a7d20a39dd215 /src/libutil/logging.hh
parent721943e1d44b63d1a4055309fad39e1f4c0f9f0d (diff)
add some comments
Diffstat (limited to 'src/libutil/logging.hh')
-rw-r--r--src/libutil/logging.hh33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index 39692a291..eeb7233e9 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -150,9 +150,23 @@ bool handleJSONLogMessage(const std::string & msg,
extern Verbosity verbosity; /* suppress msgs > this */
-/* 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. */
+/* Print a message with the standard ErrorInfo format.
+ In general, use these 'log' macros for reporting problems that may require user
+ intervention or that need more explanation. Use the 'print' macros for more
+ lightweight status messages. */
+#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)
+
+/* Print a string 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) { \
@@ -166,18 +180,7 @@ 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)
-
-
-
+/* if verbosity >= lvlWarn, print a message with a yellow 'warning:' prefix. */
template<typename... Args>
inline void warn(const std::string & fs, const Args & ... args)
{