From 63e1b2b024cd7b0b4f7965e244229e3fb9ea17a0 Mon Sep 17 00:00:00 2001 From: Eric Wild Date: Fri, 26 Nov 2021 21:09:01 +0100 Subject: [PATCH] logging: make LIBOSMOCORE_NO_LOGGING work as expected The macro introduced in d02090bba538158c36fd838d4e50c47e40f11449 was not enough: the actual logging macros are being used, i.e. by the fsm, so wrap those as well, and provide a flag to disable this at build time. Change-Id: Ia4c78abe5f198139f96ffa289998855be2477585 --- configure.ac | 11 +++++++++++ include/osmocom/core/logging.h | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/configure.ac b/configure.ac index b36bd6fa7..a69f793f9 100644 --- a/configure.ac +++ b/configure.ac @@ -366,6 +366,17 @@ then AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort]) fi +AC_ARG_ENABLE(log_macros, + [AS_HELP_STRING( + [--disable-log-macros], + [Disable logging macros that are also used internally to print information] + )], + [log_macros="yes"], [log_macros="no"]) +if test x"$log_macros" == x"yes" +then + AC_DEFINE([LIBOSMOCORE_NO_LOGGING],[1],[Disable logging macros]) +fi + AC_ARG_ENABLE(sanitize, [AS_HELP_STRING( [--enable-sanitize], diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index a95c478db..18ad3ff16 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -53,11 +53,15 @@ void logp(int subsys, const char *file, int line, int cont, const char *format, * \param[in] fmt format string * \param[in] args variable argument list */ +#ifndef LIBOSMOCORE_NO_LOGGING #define LOGPC(ss, level, fmt, args...) \ do { \ if (log_check_level(ss, level)) \ logp2(ss, level, __FILE__, __LINE__, 1, fmt, ##args); \ } while(0) +#else +#define LOGPC(ss, level, fmt, args...) +#endif /*! Log through the Osmocom logging framework with explicit source. * If caller_file is passed as NULL, __FILE__ and __LINE__ are used @@ -87,6 +91,7 @@ void logp(int subsys, const char *file, int line, int cont, const char *format, * \param[in] fmt format string * \param[in] args variable argument list */ +#ifndef LIBOSMOCORE_NO_LOGGING #define LOGPSRCC(ss, level, caller_file, caller_line, cont, fmt, args...) \ do { \ if (log_check_level(ss, level)) {\ @@ -96,6 +101,9 @@ void logp(int subsys, const char *file, int line, int cont, const char *format, logp2(ss, level, __FILE__, __LINE__, cont, fmt, ##args); \ }\ } while(0) +#else +#define LOGPSRCC(ss, level, caller_file, caller_line, cont, fmt, args...) +#endif /*! different log levels */ #define LOGL_DEBUG 1 /*!< debugging information */