Skip to content

Commit

Permalink
logging: Add basic documentation comments
Browse files Browse the repository at this point in the history
The important logging functionality was docummented.
  • Loading branch information
LukasWoodtli committed Jan 29, 2024
1 parent 40f2ff6 commit dc97acc
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions core/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,18 @@ typedef enum {
void lwm2m_log_handler(lwm2m_logging_level_t level, const char *const msg, const char *const func, const int line,
const char *const file);

/* Inspired by: https://stackoverflow.com/a/53875012 */
#define LOG_L(LEVEL, ...) LOG_ARG_L_INT(LEVEL, __VA_ARGS__, '\0')

#define LOG_ARG_L_INT(LEVEL, FMT, ...) LOG_ARG_L(LEVEL, FMT "%c", __VA_ARGS__)

/** Basic logging macro. Usually this is not called directly. Use the macros for a given level (e.g. LOG_DBG).
* Supports arguments if the message (including format specifiers) is a string literal. Otherwise the use uf
* LOG_ARG_DBG (and related macros) are needed.
* The limitation that the message needs to be a literal string is due to C11 limitations regarding empty __VA_ARGS__
* preceded by an coma. The workaround is inspired by: https://stackoverflow.com/a/53875012 */
#define LOG_L(LEVEL, ...) LOG_ARG_L_INTERNAL(LEVEL, __VA_ARGS__, '\0')

/* For internal use only. Required for workaround with empty __VA_ARGS__ in C11 */
#define LOG_ARG_L_INTERNAL(LEVEL, FMT, ...) LOG_ARG_L(LEVEL, FMT "%c", __VA_ARGS__)

/** Basic logging macro that supports arguments. Usually this is not called directly. Use the macros for a given level
* (e.g. LOG_ARG_DBG). */
#define LOG_ARG_L(LEVEL, FMT, ...) \
do { \
char txt[LWM2M_MAX_LOG_MSG_TXT_SIZE]; \
Expand Down

0 comments on commit dc97acc

Please sign in to comment.