diff options
Diffstat (limited to 'include/osmocom/core/logging.h')
-rw-r--r-- | include/osmocom/core/logging.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index 1ca348a2..fe9ae93f 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -55,10 +55,7 @@ void logp(int subsys, const char *file, int line, int cont, const char *format, * \param[in] args variable argument list */ #define LOGP(ss, level, fmt, args...) \ - do { \ - if (log_check_level(ss, level)) \ - logp2(ss, level, __BASE_FILE__, __LINE__, 0, fmt, ##args); \ - } while(0) + LOGPSRC(ss, level, NULL, 0, fmt, ## args) /*! \brief Continue a log message through the Osmocom logging framework * \param[in] ss logging subsystem (e.g. \ref DLGLOBAL) @@ -72,6 +69,28 @@ void logp(int subsys, const char *file, int line, int cont, const char *format, logp2(ss, level, __BASE_FILE__, __LINE__, 1, fmt, ##args); \ } while(0) +/*! \brief Log through the Osmocom logging framework with explicit source. + * If caller_file is passed as NULL, __BASE_FILE__ and __LINE__ are used + * instead of caller_file and caller_line (so that this macro here defines + * both cases in the same place, and to catch cases where callers fail to pass + * a non-null filename string). + * \param[in] ss logging subsystem (e.g. \ref DLGLOBAL) + * \param[in] level logging level (e.g. \ref LOGL_NOTICE) + * \param[in] caller_file caller's source file string (e.g. __BASE_FILE__) + * \param[in] caller_line caller's source line nr (e.g. __LINE__) + * \param[in] fmt format string + * \param[in] args variable argument list + */ +#define LOGPSRC(ss, level, caller_file, caller_line, fmt, args...) \ + do { \ + if (log_check_level(ss, level)) {\ + if (caller_file) \ + logp2(ss, level, caller_file, caller_line, 0, fmt, ##args); \ + else \ + logp2(ss, level, __BASE_FILE__, __LINE__, 0, fmt, ##args); \ + }\ + } while(0) + /*! \brief different log levels */ #define LOGL_DEBUG 1 /*!< \brief debugging information */ #define LOGL_INFO 3 /*!< \brief general information */ |