2019-07-17 09:58:59 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Nordic Semiconductor ASA
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
#ifndef ZEPHYR_LOG_BACKEND_STD_H_
|
|
|
|
#define ZEPHYR_LOG_BACKEND_STD_H_
|
|
|
|
|
2022-06-21 11:32:21 +02:00
|
|
|
#include <zephyr/logging/log_msg.h>
|
2022-05-06 10:30:42 +02:00
|
|
|
#include <zephyr/logging/log_output.h>
|
|
|
|
#include <zephyr/kernel.h>
|
2019-07-17 09:58:59 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-09-21 15:29:02 +02:00
|
|
|
/**
|
|
|
|
* @brief Logger backend interface for forwarding to standard backend
|
|
|
|
* @defgroup log_backend_std Logger backend standard interface
|
|
|
|
* @ingroup logger
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2020-12-22 19:55:11 +01:00
|
|
|
static inline uint32_t log_backend_std_get_flags(void)
|
|
|
|
{
|
|
|
|
uint32_t flags = (LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_TIMESTAMP);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-08-30 14:05:12 +02:00
|
|
|
if (IS_ENABLED(CONFIG_LOG_THREAD_ID_PREFIX)) {
|
|
|
|
flags |= LOG_OUTPUT_FLAG_THREAD;
|
|
|
|
}
|
|
|
|
|
2020-12-22 19:55:11 +01:00
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2019-07-17 09:58:59 +02:00
|
|
|
/** @brief Put a standard logger backend into panic mode.
|
|
|
|
*
|
2021-03-22 14:47:05 +01:00
|
|
|
* @param output Log output instance.
|
2019-07-17 09:58:59 +02:00
|
|
|
*/
|
|
|
|
static inline void
|
2021-03-22 14:47:05 +01:00
|
|
|
log_backend_std_panic(const struct log_output *const output)
|
2019-07-17 09:58:59 +02:00
|
|
|
{
|
2021-03-22 14:47:05 +01:00
|
|
|
log_output_flush(output);
|
2019-07-17 09:58:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Report dropped messages to a standard logger backend.
|
|
|
|
*
|
2021-03-22 14:47:05 +01:00
|
|
|
* @param output Log output instance.
|
2019-07-17 09:58:59 +02:00
|
|
|
* @param cnt Number of dropped messages.
|
|
|
|
*/
|
|
|
|
static inline void
|
2021-03-22 14:47:05 +01:00
|
|
|
log_backend_std_dropped(const struct log_output *const output, uint32_t cnt)
|
2019-07-17 09:58:59 +02:00
|
|
|
{
|
2021-03-22 14:47:05 +01:00
|
|
|
log_output_dropped_process(output, cnt);
|
2019-07-17 09:58:59 +02:00
|
|
|
}
|
|
|
|
|
2020-09-21 15:29:02 +02:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2019-07-17 09:58:59 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* ZEPHYR_LOG_BACKEND_STD_H_ */
|