logging: make LIBOSMOCORE_NO_LOGGING work as expected

The macro introduced in d02090bba5 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
This commit is contained in:
Eric Wild 2021-11-26 21:09:01 +01:00 committed by laforge
parent e6987e96b6
commit 63e1b2b024
2 changed files with 19 additions and 0 deletions

View File

@ -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],

View File

@ -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 */