From ca6fb5aa5f8db487b283b84aee3eaaeaa88c8596 Mon Sep 17 00:00:00 2001 From: Rob Riggs Date: Sun, 28 Oct 2018 21:27:27 -0500 Subject: [PATCH] Minor logging improvements. --- TNC/Log.cpp | 2 ++ TNC/Log.h | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/TNC/Log.cpp b/TNC/Log.cpp index 22f1869..a913a31 100644 --- a/TNC/Log.cpp +++ b/TNC/Log.cpp @@ -2,6 +2,8 @@ // All rights reserved. #include +#include +#include void log_(int level, const char* fmt, ...) { diff --git a/TNC/Log.h b/TNC/Log.h index f1153b7..25baf66 100644 --- a/TNC/Log.h +++ b/TNC/Log.h @@ -20,12 +20,19 @@ extern "C" { void log_(int level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +#ifndef KISS_LOG_LEVEL +#define KISS_LOG_LEVEL 0 +#endif + #ifdef KISS_LOGGING -#define DEBUG(...) log_(0, __VA_ARGS__) -#define INFO(...) log_(1, __VA_ARGS__) -#define WARN(...) log_(2, __VA_ARGS__) -#define ERROR(...) log_(3, __VA_ARGS__) -#define SEVERE(...) log_(4, __VA_ARGS__) + +#define LOG(level, ...) if(level >= KISS_LOG_LEVEL) log_(level, __VA_ARGS__); + +#define DEBUG(...) LOG(0, __VA_ARGS__) +#define INFO(...) LOG(1, __VA_ARGS__) +#define WARN(...) LOG(2, __VA_ARGS__) +#define ERROR(...) LOG(3, __VA_ARGS__) +#define SEVERE(...) LOG(4, __VA_ARGS__) #else #define DEBUG(...) #define INFO(...)