logging: Add support for new 'in place' mode to UART backend
Extended UART backend to support new backend API for 'in place' mode. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
80a60412c9
commit
71697969c7
|
@ -70,11 +70,56 @@ static void dropped(const struct log_backend *const backend, u32_t cnt)
|
|||
log_output_dropped_process(&log_output, cnt);
|
||||
}
|
||||
|
||||
static void sync_string(const struct log_backend *const backend,
|
||||
struct log_msg_ids src_level, u32_t timestamp,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
u32_t flags = LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_TIMESTAMP;
|
||||
u32_t key;
|
||||
|
||||
if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
|
||||
flags |= LOG_OUTPUT_FLAG_COLORS;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
|
||||
flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
|
||||
}
|
||||
|
||||
key = irq_lock();
|
||||
log_output_string(&log_output, src_level, timestamp, fmt, ap, flags);
|
||||
irq_unlock(key);
|
||||
}
|
||||
|
||||
static void sync_hexdump(const struct log_backend *const backend,
|
||||
struct log_msg_ids src_level, u32_t timestamp,
|
||||
const char *metadata, const u8_t *data, u32_t length)
|
||||
{
|
||||
u32_t flags = LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_TIMESTAMP;
|
||||
u32_t key;
|
||||
|
||||
if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
|
||||
flags |= LOG_OUTPUT_FLAG_COLORS;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
|
||||
flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
|
||||
}
|
||||
|
||||
key = irq_lock();
|
||||
log_output_hexdump(&log_output, src_level, timestamp,
|
||||
metadata, data, length, flags);
|
||||
irq_unlock(key);
|
||||
}
|
||||
|
||||
const struct log_backend_api log_backend_uart_api = {
|
||||
.put = put,
|
||||
.put = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : put,
|
||||
.put_sync_string = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ?
|
||||
sync_string : NULL,
|
||||
.put_sync_hexdump = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ?
|
||||
sync_hexdump : NULL,
|
||||
.panic = panic,
|
||||
.init = log_backend_uart_init,
|
||||
.dropped = dropped,
|
||||
.dropped = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : dropped,
|
||||
};
|
||||
|
||||
LOG_BACKEND_DEFINE(log_backend_uart, log_backend_uart_api, true);
|
||||
|
|
Loading…
Reference in a new issue