From 48cb5f925d3bf21c51818dbe46c864a6975ccc75 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 16 May 2016 11:04:26 +0100 Subject: [PATCH] Add olm::log_enabled_for --- include/olm/logging.hh | 2 ++ src/logging.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/olm/logging.hh b/include/olm/logging.hh index f174712..ff84615 100644 --- a/include/olm/logging.hh +++ b/include/olm/logging.hh @@ -27,6 +27,8 @@ const unsigned int LOG_TRACE = 6; void set_log_level(unsigned int log_level); +bool log_enabled_for(unsigned int level, const char *category); + __attribute__((__format__ (__printf__, 3, 4))) void logf(unsigned int level, const char *category, const char *format, ...); diff --git a/src/logging.cpp b/src/logging.cpp index 66b9fa8..4819e1c 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -26,6 +26,11 @@ void set_log_level(unsigned int level) { log_level = level; } +bool log_enabled_for(unsigned int level, const char *category) +{ + return level <= log_level; +} + void logf(unsigned int level, const char *category, const char *format, ...) { if (level > log_level) {