Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions include/logging/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,7 @@ int log_printk(const char *fmt, va_list ap);
* - Instance logging is used and there is no need to create module entry.
*/

#if defined(LOG_MODULE_NAME) && \
((defined(LOG_LEVEL) && (LOG_LEVEL > LOG_LEVEL_NONE)) || \
(!defined(LOG_LEVEL) && (CONFIG_LOG_DEFAULT_LEVEL > LOG_LEVEL_NONE)))
#if LOG_MODULE_PRESENT
#if CONFIG_LOG_RUNTIME_FILTERING
#define LOG_MODULE_REGISTER() \
_LOG_CONST_ITEM_REGISTER(LOG_MODULE_NAME, \
Expand All @@ -279,9 +277,9 @@ int log_printk(const char *fmt, va_list ap);
CONFIG_LOG_DEFAULT_LEVEL))
#endif /*CONFIG_LOG_RUNTIME_FILTERING*/

#else /* LOG enabled for the module. */
#else /* LOG_MODULE_PRESENT */
#define LOG_MODULE_REGISTER() /* Empty */
#endif
#endif /* LOG_MODULE_PRESENT */

/**
* @}
Expand Down
57 changes: 55 additions & 2 deletions include/logging/log_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ extern "C" {

#define LOG_LEVEL_BITS 3

/* Conditions determining if logger is used in a module on any level. */
#if CONFIG_LOG && \
((defined(LOG_LEVEL) && LOG_LEVEL) || \
(!defined(LOG_LEVEL) && CONFIG_LOG_DEFAULT_LEVEL))
#define LOG_MODULE_PRESENT 1
#else
#define LOG_MODULE_PRESENT 0
#endif


/** @brief Macro for returning local level value if defined or default.
*
* Check @ref IS_ENABLED macro for detailed explanation of the trick.
Expand All @@ -47,6 +57,49 @@ extern "C" {

#define __LOG_RESOLVED_LEVEL3(ignore_this, val, ...) val


/**
* @def LOG_CONST_ID_GET
* @brief Macro for getting ID of the element of the section.
*
* @param _addr Address of the element.
*/
/**
* @def LOG_CURRENT_MODULE_ID
* @brief Macro for getting ID of current module.
*/
/**
* @def LOG_CURRENT_DYNAMIC_DATA_ADDR
* @brief Macro for getting address of dynamic structure of current module.
*/
#if LOG_MODULE_PRESENT
#define LOG_CONST_ID_GET(_addr) \
log_const_source_id((const struct log_source_const_data *)_addr)

#define LOG_CURRENT_MODULE_ID() \
log_const_source_id(&LOG_ITEM_CONST_DATA(LOG_MODULE_NAME))

#define LOG_CURRENT_DYNAMIC_DATA_ADDR() \
(&LOG_ITEM_DYNAMIC_DATA(LOG_MODULE_NAME))
#else /* LOG_MODULE_PRESENT */
#define LOG_CONST_ID_GET(_addr) 0

#define LOG_CURRENT_MODULE_ID() 0

#define LOG_CURRENT_DYNAMIC_DATA_ADDR() ((struct log_source_dynamic_data *)0)
#endif /* LOG_MODULE_PRESENT */

/** @brief Macro for getting ID of the element of the section.
*
* @param _addr Address of the element.
*/
#if LOG_MODULE_PRESENT
#define LOG_DYNAMIC_ID_GET(_addr) \
log_dynamic_source_id((struct log_source_dynamic_data *)_addr)
#else
#define LOG_DYNAMIC_ID_GET(_addr) 0
#endif

/******************************************************************************/
/****************** Internal macros for log frontend **************************/
/******************************************************************************/
Expand Down Expand Up @@ -130,7 +183,7 @@ extern "C" {
#define _LOG(_level, ...) \
__LOG(_level, \
LOG_CURRENT_MODULE_ID(), \
&LOG_ITEM_DYNAMIC_DATA(LOG_MODULE_NAME), \
LOG_CURRENT_DYNAMIC_DATA_ADDR(), \
__VA_ARGS__)

#define _LOG_INSTANCE(_level, _inst, ...) \
Expand Down Expand Up @@ -161,7 +214,7 @@ extern "C" {
#define _LOG_HEXDUMP(_level, _data, _length) \
__LOG_HEXDUMP(_level, \
LOG_CURRENT_MODULE_ID(), \
&LOG_ITEM_DYNAMIC_DATA(LOG_MODULE_NAME), \
LOG_CURRENT_DYNAMIC_DATA_ADDR(), \
_data, _length)

#define _LOG_HEXDUMP_INSTANCE(_level, _inst, _data, _length) \
Expand Down
40 changes: 0 additions & 40 deletions include/logging/log_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,37 +109,6 @@ static inline u32_t log_dynamic_source_id(struct log_source_dynamic_data *data)
sizeof(struct log_source_dynamic_data);
}

/**
* @def LOG_CONST_ID_GET
* @brief Macro for getting ID of the element of the section.
*
* @param _addr Address of the element.
*/
/**
* @def LOG_CURRENT_MODULE_ID
* @brief Macro for getting ID of current module.
*/
#ifdef CONFIG_LOG
#define LOG_CONST_ID_GET(_addr) \
log_const_source_id((const struct log_source_const_data *)_addr)
#define LOG_CURRENT_MODULE_ID() \
log_const_source_id(&LOG_ITEM_CONST_DATA(LOG_MODULE_NAME))
#else
#define LOG_CONST_ID_GET(_addr) 0
#define LOG_CURRENT_MODULE_ID() 0
#endif

/** @brief Macro for getting ID of the element of the section.
*
* @param _addr Address of the element.
*/
#if CONFIG_LOG
#define LOG_DYNAMIC_ID_GET(_addr) \
log_dynamic_source_id((struct log_source_dynamic_data *)_addr)
#else
#define LOG_DYNAMIC_ID_GET(_addr) 0
#endif

/******************************************************************************/
/****************** Filtering macros ******************************************/
/******************************************************************************/
Expand Down Expand Up @@ -192,15 +161,6 @@ static inline u32_t log_dynamic_source_id(struct log_source_dynamic_data *data)
.level = (_level), \
}

#if CONFIG_LOG_RUNTIME_FILTERING
#define _LOG_DYNAMIC_ITEM_REGISTER(_name) \
struct log_source_dynamic_data LOG_ITEM_DYNAMIC_DATA(_name) \
__attribute__ ((section("." STRINGIFY(LOG_ITEM_DYNAMIC_DATA(_name))))) \
__attribute__((used))
#else
#define _LOG_DYNAMIC_ITEM_REGISTER(_name) /* empty */
#endif

/** @def LOG_INSTANCE_PTR_DECLARE
* @brief Macro for declaring a logger instance pointer in the module structure.
*/
Expand Down