logging: Cleaning up log minimal
Removed printk.h include from log_core.h. Since LOG_PRINTK cannot be enabled with LOG_MINIMAL removed support for both. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
5b6de52a71
commit
e0392c5a86
3 changed files with 33 additions and 24 deletions
|
@ -241,7 +241,6 @@ extern "C" {
|
|||
#define LOG_INST_HEXDUMP_DBG(_log_inst, _data, _length, _str) \
|
||||
Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_DBG, _log_inst, _data, _length, _str)
|
||||
|
||||
#ifndef CONFIG_LOG_MINIMAL
|
||||
/**
|
||||
* @brief Writes an formatted string to the log.
|
||||
*
|
||||
|
@ -255,6 +254,7 @@ extern "C" {
|
|||
*/
|
||||
void log_printk(const char *fmt, va_list ap);
|
||||
|
||||
#ifndef CONFIG_LOG_MINIMAL
|
||||
/** @brief Copy transient string to a buffer from internal, logger pool.
|
||||
*
|
||||
* Function should be used when transient string is intended to be logged.
|
||||
|
@ -274,10 +274,6 @@ void log_printk(const char *fmt, va_list ap);
|
|||
*/
|
||||
char *log_strdup(const char *str);
|
||||
#else
|
||||
static inline void log_printk(const char *fmt, va_list ap)
|
||||
{
|
||||
vprintk(fmt, ap);
|
||||
}
|
||||
|
||||
static inline char *log_strdup(const char *str)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <stdarg.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/util.h>
|
||||
#include <sys/printk.h>
|
||||
|
||||
#define LOG_LEVEL_NONE 0U
|
||||
#define LOG_LEVEL_ERR 1U
|
||||
|
@ -232,12 +231,15 @@ extern "C" {
|
|||
/******************************************************************************/
|
||||
/****************** Defiinitions used by minimal logging **********************/
|
||||
/******************************************************************************/
|
||||
void log_minimal_hexdump_print(int level, const void *data, size_t size);
|
||||
void z_log_minimal_hexdump_print(int level, const void *data, size_t size);
|
||||
void z_log_minimal_vprintk(const char *fmt, va_list ap);
|
||||
void z_log_minimal_printk(const char *fmt, ...);
|
||||
|
||||
#define Z_LOG_TO_PRINTK(_level, fmt, ...) do { \
|
||||
printk("%c: " fmt "\n", z_log_minimal_level_to_char(_level), \
|
||||
##__VA_ARGS__); \
|
||||
} while (false)
|
||||
#define Z_LOG_TO_PRINTK(_level, fmt, ...) do { \
|
||||
z_log_minimal_printk("%c: " fmt "\n", \
|
||||
z_log_minimal_level_to_char(_level), \
|
||||
##__VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
static inline char z_log_minimal_level_to_char(int level)
|
||||
{
|
||||
|
@ -264,8 +266,8 @@ static inline char z_log_minimal_level_to_char(int level)
|
|||
\
|
||||
if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \
|
||||
Z_LOG_TO_PRINTK(_level, __VA_ARGS__); \
|
||||
} else if (LOG_CHECK_CTX_LVL_FILTER(is_user_context, \
|
||||
_level, _filter)) { \
|
||||
} else if (LOG_CHECK_CTX_LVL_FILTER(is_user_context, \
|
||||
_level, _filter)) { \
|
||||
struct log_msg_ids src_level = { \
|
||||
.level = _level, \
|
||||
.domain_id = CONFIG_LOG_DOMAIN_ID, \
|
||||
|
@ -282,8 +284,8 @@ static inline char z_log_minimal_level_to_char(int level)
|
|||
src_level, \
|
||||
__VA_ARGS__); \
|
||||
} \
|
||||
} else { \
|
||||
} \
|
||||
} else { \
|
||||
} \
|
||||
} \
|
||||
if (false) { \
|
||||
/* Arguments checker present but never evaluated.*/ \
|
||||
|
@ -318,11 +320,11 @@ static inline char z_log_minimal_level_to_char(int level)
|
|||
\
|
||||
if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \
|
||||
Z_LOG_TO_PRINTK(_level, "%s", _str); \
|
||||
log_minimal_hexdump_print(_level, \
|
||||
z_log_minimal_hexdump_print(_level, \
|
||||
(const char *)_data, \
|
||||
_length); \
|
||||
} else if (LOG_CHECK_CTX_LVL_FILTER(is_user_context,\
|
||||
_level, _filter)) { \
|
||||
} else if (LOG_CHECK_CTX_LVL_FILTER(is_user_context, \
|
||||
_level, _filter)) { \
|
||||
struct log_msg_ids src_level = { \
|
||||
.level = _level, \
|
||||
.domain_id = CONFIG_LOG_DOMAIN_ID, \
|
||||
|
@ -724,11 +726,7 @@ __syscall void z_log_hexdump_from_user(uint32_t src_level_val,
|
|||
bool is_user_context = _is_user_context(); \
|
||||
\
|
||||
if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \
|
||||
if (IS_ENABLED(CONFIG_LOG_PRINTK)) { \
|
||||
log_printk(_str, _valist); \
|
||||
} else { \
|
||||
vprintk(_str, _valist); \
|
||||
} \
|
||||
z_log_minimal_printk(_str, _valist); \
|
||||
} else if (LOG_CHECK_CTX_LVL_FILTER(is_user_context, \
|
||||
_level, _filter)) { \
|
||||
struct log_msg_ids src_level = { \
|
||||
|
|
|
@ -7,9 +7,24 @@
|
|||
#include <sys/printk.h>
|
||||
#include <ctype.h>
|
||||
#include <logging/log.h>
|
||||
#include <sys/printk.h>
|
||||
|
||||
#define HEXDUMP_BYTES_IN_LINE 8
|
||||
|
||||
void z_log_minimal_printk(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vprintk(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void z_log_minimal_vprintk(const char *fmt, va_list ap)
|
||||
{
|
||||
vprintk(fmt, ap);
|
||||
}
|
||||
|
||||
static void minimal_hexdump_line_print(const char *data, size_t length)
|
||||
{
|
||||
for (size_t i = 0; i < HEXDUMP_BYTES_IN_LINE; i++) {
|
||||
|
@ -34,7 +49,7 @@ static void minimal_hexdump_line_print(const char *data, size_t length)
|
|||
printk("\n");
|
||||
}
|
||||
|
||||
void log_minimal_hexdump_print(int level, const void *_data, size_t size)
|
||||
void z_log_minimal_hexdump_print(int level, const void *_data, size_t size)
|
||||
{
|
||||
const char *data = (const char *)_data;
|
||||
while (size > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue