Skip to content
Permalink
Browse files

logging: Allow logger usage in C++ files

Allow usage of LOG_MODULE_REGISTER and LOG_MODULE_DECLARE in
C++.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
  • Loading branch information...
nordic-krch authored and nashif committed Apr 24, 2019
1 parent 18833ac commit 0bfd28361efdd37d88365038ebb1a63af027fae9
Showing with 7 additions and 9 deletions.
  1. +7 −9 include/logging/log.h
@@ -276,6 +276,10 @@ int log_printk(const char *fmt, va_list ap);
*/
char *log_strdup(const char *str);

#ifdef __cplusplus
}
#define LOG_IN_CPLUSPLUS 1
#endif
/* Macro expects that optionally on second argument local log level is provided.
* If provided it is returned, otherwise default log level is returned or
* LOG_LEVEL, if it was locally defined.
@@ -292,8 +296,8 @@ char *log_strdup(const char *str);
/* Return first argument */
#define _LOG_ARG1(arg1, ...) arg1


#define _LOG_MODULE_CONST_DATA_CREATE(_name, _level) \
COND_CODE_1(LOG_IN_CPLUSPLUS, (extern), ()) \
const struct log_source_const_data LOG_ITEM_CONST_DATA(_name) \
__attribute__ ((section("." STRINGIFY(LOG_ITEM_CONST_DATA(_name))))) \
__attribute__((used)) = { \
@@ -309,8 +313,8 @@ char *log_strdup(const char *str);
__attribute__((used))

#define _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name) \
Z_LOG_EVAL( \
IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING), \
COND_CODE_1( \
CONFIG_LOG_RUNTIME_FILTERING, \
(_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);), \
() \
)
@@ -351,7 +355,6 @@ char *log_strdup(const char *str);
* @see LOG_MODULE_DECLARE
*/


#define LOG_MODULE_REGISTER(...) \
Z_LOG_EVAL( \
_LOG_LEVEL_RESOLVE(__VA_ARGS__), \
@@ -422,9 +425,4 @@ char *log_strdup(const char *str);
* @}
*/


#ifdef __cplusplus
}
#endif

#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_H_ */

0 comments on commit 0bfd283

Please sign in to comment.
You can’t perform that action at this time.