logging: Add option to have tag which is prepended to all messages
Tag can be changed at runtime. Feature is enabled by setting maximum tag length to positive value. Additionally, default tag can be configured in Kconfig. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
27db56468a
commit
194c0acdfd
5 changed files with 75 additions and 1 deletions
|
@ -210,6 +210,17 @@ static inline bool log_data_pending(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure tag used to prefix each message.
|
||||
*
|
||||
* @param tag Tag.
|
||||
*
|
||||
* @retval 0 on successful operation.
|
||||
* @retval -ENOTSUP if feature is disabled.
|
||||
* @retval -ENOMEM if string is longer than the buffer capacity. Tag will be trimmed.
|
||||
*/
|
||||
int log_set_tag(const char *tag);
|
||||
|
||||
#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL)
|
||||
#define LOG_CORE_INIT() log_core_init()
|
||||
#define LOG_INIT() log_init()
|
||||
|
|
|
@ -95,6 +95,12 @@ void z_log_msg2_free(union log_msg2_generic *msg);
|
|||
*/
|
||||
bool z_log_msg2_pending(void);
|
||||
|
||||
/** @brief Get tag.
|
||||
*
|
||||
* @return Tag. Null if feature is disabled.
|
||||
*/
|
||||
const char *z_log_get_tag(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue