logging: Added support for 10 arguments in log message

Extended supported number of arguments in log message. Support for
messages consisting of more than 2 chunks had to be added. So far
messages could consist of one chunk (up to 3 args) or two chunks
(2 args in first chunk and 7 in second chunk). Once 2+ chunks
support is added number of arguments is techinically limited to
15 (4 bit field). log_core and log_output extended to suppor 10
arguments.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2018-10-23 19:44:44 +02:00 committed by Anas Nashif
commit c696e68bb9
6 changed files with 130 additions and 71 deletions

View file

@ -174,6 +174,9 @@ extern "C" {
#define _LOG_INTERNAL_9(_src_level, _str, ...) \
_LOG_INTERNAL_LONG(_src_level, _str, __VA_ARGS__)
#define _LOG_INTERNAL_10(_src_level, _str, ...) \
_LOG_INTERNAL_LONG(_src_level, _str, __VA_ARGS__)
#define _LOG_LEVEL_CHECK(_level, _check_level, _default_level) \
(_level <= _LOG_RESOLVED_LEVEL(_check_level, _default_level))

View file

@ -22,8 +22,11 @@ extern "C" {
* @{
*/
/** @brief Maximum number of arguments in the standard log entry. */
#define LOG_MAX_NARGS 9
/** @brief Maximum number of arguments in the standard log entry.
*
* It is limited by 4 bit nargs field in the log message.
*/
#define LOG_MAX_NARGS 15
/** @brief Number of arguments in the log entry which fits in one chunk.*/
#define LOG_MSG_NARGS_SINGLE_CHUNK 3
@ -357,36 +360,6 @@ static inline struct log_msg *_log_msg_std_alloc(void)
return msg;
}
/** @brief Allocate chunk for extended standard log message.
*
* @details Extended standard log message is used when number of arguments
* exceeds capacity of one chunk. Extended message consists of two
* chunks. Such approach is taken to optimize memory usage and
* performance assuming that log messages with more arguments
* (@ref LOG_MSG_NARGS_SINGLE_CHUNK) are less common.
*
* @return Allocated chunk of NULL.
*/
static inline struct log_msg *_log_msg_ext_std_alloc(void)
{
struct log_msg_cont *cont;
struct log_msg *msg = _log_msg_std_alloc();
if (msg != NULL) {
cont = (struct log_msg_cont *)log_msg_chunk_alloc();
if (cont == NULL) {
k_mem_slab_free(&log_msg_pool, (void **)&msg);
return NULL;
}
msg->hdr.params.generic.ext = 1;
msg->payload.ext.next = cont;
cont->next = NULL;
}
return msg;
}
/** @brief Create standard log message with no arguments.
*
* @details Function resets header and sets following fields: