6#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_MSG_H_
7#define ZEPHYR_INCLUDE_LOGGING_LOG_MSG_H_
35#define LOG_MAX_NARGS 15
39#define LOG_MSG_NARGS_SINGLE_CHUNK 4U
41#define LOG_MSG_NARGS_SINGLE_CHUNK 3U
45#define LOG_MSG_NARGS_HEAD_CHUNK \
46 (LOG_MSG_NARGS_SINGLE_CHUNK - (sizeof(void *)/sizeof(log_arg_t)))
50#define LOG_MSG_HEXDUMP_BYTES_SINGLE_CHUNK \
51 (LOG_MSG_NARGS_SINGLE_CHUNK * sizeof(log_arg_t))
56#define LOG_MSG_HEXDUMP_BYTES_HEAD_CHUNK \
57 (LOG_MSG_HEXDUMP_BYTES_SINGLE_CHUNK - sizeof(void *))
62#define HEXDUMP_BYTES_CONT_MSG \
63 (sizeof(struct log_msg) - sizeof(void *))
65#define ARGS_CONT_MSG (HEXDUMP_BYTES_CONT_MSG / sizeof(log_arg_t))
68#define LOG_MSG_TYPE_STD 0U
71#define LOG_MSG_TYPE_HEXDUMP 1
74#define COMMON_PARAM_HDR() \
79#define LOG_MSG_HEXDUMP_LENGTH_BITS 14
82#define LOG_MSG_HEXDUMP_MAX_LENGTH (BIT(LOG_MSG_HEXDUMP_LENGTH_BITS) - 1)
322static inline struct log_msg *z_log_msg_std_alloc(
void)
353 struct log_msg *msg = z_log_msg_std_alloc();
378 struct log_msg *msg = z_log_msg_std_alloc();
407 struct log_msg *msg = z_log_msg_std_alloc();
439 struct log_msg *msg = z_log_msg_std_alloc();
int atomic_t
Definition: atomic.h:21
void log_msg_pool_init(void)
Function for initialization of the log message pool.
static uint32_t log_msg_level_get(struct log_msg *msg)
Get severity level of the message.
Definition: log_msg.h:213
#define LOG_MSG_NARGS_SINGLE_CHUNK
Number of arguments in the log entry which fits in one chunk.
Definition: log_msg.h:41
#define LOG_MSG_HEXDUMP_LENGTH_BITS
Number of bits used for storing length of hexdump log message.
Definition: log_msg.h:79
#define LOG_MSG_HEXDUMP_BYTES_HEAD_CHUNK
Number of bytes in the first chunk of hexdump message if message consists of more than one chunk.
Definition: log_msg.h:56
static uint32_t log_msg_timestamp_get(struct log_msg *msg)
Get timestamp of the message.
Definition: log_msg.h:224
#define COMMON_PARAM_HDR()
Common part of log message header.
Definition: log_msg.h:74
static struct log_msg * log_msg_create_3(const char *str, log_arg_t arg1, log_arg_t arg2, log_arg_t arg3)
Create standard log message with three arguments.
Definition: log_msg.h:434
static uint32_t log_msg_domain_id_get(struct log_msg *msg)
Get domain ID of the message.
Definition: log_msg.h:191
void log_msg_hexdump_data_put(struct log_msg *msg, uint8_t *data, size_t *length, size_t offset)
Put data into hexdump log message.
unsigned long log_arg_t
Log argument type.
Definition: log_msg.h:29
const char * log_msg_str_get(struct log_msg *msg)
Gets pointer to the unformatted string from standard log message.
#define HEXDUMP_BYTES_CONT_MSG
Number of bytes that can be stored in chunks following head chunk in hexdump log message.
Definition: log_msg.h:62
static uint32_t log_msg_source_id_get(struct log_msg *msg)
Get source ID (module or instance) of the message.
Definition: log_msg.h:202
union log_msg_chunk * log_msg_no_space_handle(void)
uint32_t log_msg_nargs_get(struct log_msg *msg)
Returns number of arguments in standard log message.
void log_msg_hexdump_data_get(struct log_msg *msg, uint8_t *data, size_t *length, size_t offset)
Get data from hexdump log message.
static bool log_msg_is_std(struct log_msg *msg)
Check if message is of standard type.
Definition: log_msg.h:236
struct log_msg * log_msg_hexdump_create(const char *str, const uint8_t *data, uint32_t length)
Allocates chunks for hexdump message and copies the data.
static struct log_msg * log_msg_create_2(const char *str, log_arg_t arg1, log_arg_t arg2)
Create standard log message with two arguments.
Definition: log_msg.h:403
static struct log_msg * log_msg_create_0(const char *str)
Create standard log message with no arguments.
Definition: log_msg.h:351
void log_msg_put(struct log_msg *msg)
Function for indicating that message is no longer in use.
uint32_t log_msg_mem_get_used(void)
Get number of used blocks from the log mem pool.
log_arg_t log_msg_arg_get(struct log_msg *msg, uint32_t arg_idx)
Gets argument from standard log message.
#define LOG_MSG_HEXDUMP_BYTES_SINGLE_CHUNK
Maximal amount of bytes in the hexdump entry which fits in one chunk.
Definition: log_msg.h:50
void log_msg_get(struct log_msg *msg)
Function for indicating that message is in use.
#define ARGS_CONT_MSG
Definition: log_msg.h:65
#define LOG_MSG_NARGS_HEAD_CHUNK
Number of arguments in the head of extended standard log message..
Definition: log_msg.h:45
struct log_msg * log_msg_create_n(const char *str, log_arg_t *args, uint32_t nargs)
Create standard log message with variable number of arguments.
union log_msg_chunk * log_msg_chunk_alloc(void)
Allocate single chunk from the pool.
uint32_t log_msg_mem_get_free(void)
Get number of free blocks from the log mem pool.
#define LOG_MSG_TYPE_STD
Flag indicating standard log message.
Definition: log_msg.h:68
static struct log_msg * log_msg_create_1(const char *str, log_arg_t arg1)
Create standard log message with one argument.
Definition: log_msg.h:375
uint32_t log_msg_mem_get_max_used(void)
Get max used blocks from the log mem pool.
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:101
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Chunks following message head when message is extended.
Definition: log_msg.h:150
union log_msg_cont::log_msg_cont_data payload
struct log_msg_cont * next
Definition: log_msg.h:151
Data part of extended log message.
Definition: log_msg.h:130
union log_msg_ext_head_data::log_msg_ext_head_data_data data
struct log_msg_cont * next
Definition: log_msg.h:131
uint16_t reserved
Definition: log_msg.h:94
uint16_t type
Definition: log_msg.h:93
Definition: log_msg.h:111
uint32_t timestamp
Definition: log_msg.h:120
atomic_t ref_cnt
Definition: log_msg.h:112
union log_msg_hdr::log_msg_hdr_params params
struct log_msg_ids ids
Definition: log_msg.h:119
Definition: log_msg.h:105
uint16_t length
Definition: log_msg.h:107
Part of log message header identifying source and level.
Definition: log_msg.h:85
uint16_t level
Definition: log_msg.h:86
uint16_t domain_id
Definition: log_msg.h:87
uint16_t source_id
Definition: log_msg.h:88
uint16_t reserved
Definition: log_msg.h:100
uint16_t type
Definition: log_msg.h:99
uint16_t nargs
Definition: log_msg.h:101
Log message structure.
Definition: log_msg.h:139
union log_msg::log_msg_data payload
const char * str
Definition: log_msg.h:142
struct log_msg_hdr hdr
Definition: log_msg.h:141
struct log_msg * next
Definition: log_msg.h:140
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
Definition: log_msg.h:143
struct log_msg_ext_head_data ext
Definition: log_msg.h:145
union log_msg_head_data single
Definition: log_msg.h:144
Log message.
Definition: log_msg.h:159
struct log_msg head
Definition: log_msg.h:160
struct log_msg_cont cont
Definition: log_msg.h:161
Definition: log_msg.h:152
uint8_t bytes[(sizeof(struct log_msg) - sizeof(void *))]
Definition: log_msg.h:154
log_arg_t args[((sizeof(struct log_msg) - sizeof(void *))/sizeof(log_arg_t))]
Definition: log_msg.h:153
Definition: log_msg.h:132
log_arg_t args[(3U -(sizeof(void *)/sizeof(log_arg_t)))]
Definition: log_msg.h:133
uint8_t bytes[((3U *sizeof(log_arg_t)) - sizeof(void *))]
Definition: log_msg.h:134
Definition: log_msg.h:113
uint16_t raw
Definition: log_msg.h:117
struct log_msg_generic_hdr generic
Definition: log_msg.h:114
struct log_msg_hexdump_hdr hexdump
Definition: log_msg.h:116
struct log_msg_std_hdr std
Definition: log_msg.h:115
Data part of log message.
Definition: log_msg.h:124
uint8_t bytes[(3U *sizeof(log_arg_t))]
Definition: log_msg.h:126
log_arg_t args[3U]
Definition: log_msg.h:125