Line data Source code
1 0 : /*
2 : * Copyright (c) 2019 Nordic Semiconductor ASA
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 : #ifndef ZEPHYR_LOG_BACKEND_STD_H_
7 : #define ZEPHYR_LOG_BACKEND_STD_H_
8 :
9 : #include <zephyr/logging/log_msg.h>
10 : #include <zephyr/logging/log_output.h>
11 : #include <zephyr/kernel.h>
12 :
13 : #ifdef __cplusplus
14 : extern "C" {
15 : #endif
16 :
17 : /**
18 : * @brief Logger backend interface for forwarding to standard backend
19 : * @defgroup log_backend_std Logger backend standard interface
20 : * @ingroup logger
21 : * @{
22 : */
23 :
24 : /**
25 : * @brief Retrieve the current flags of the standard logger backend interface
26 : *
27 : * @return A bitmask of the active flags defined at compilation time.
28 : */
29 1 : static inline uint32_t log_backend_std_get_flags(void)
30 : {
31 : uint32_t flags = 0;
32 :
33 : if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_TIMESTAMP)) {
34 : flags |= LOG_OUTPUT_FLAG_TIMESTAMP;
35 : }
36 :
37 : if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_LEVEL)) {
38 : flags |= LOG_OUTPUT_FLAG_LEVEL;
39 : }
40 :
41 : if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
42 : flags |= LOG_OUTPUT_FLAG_COLORS;
43 : }
44 :
45 : if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
46 : flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
47 : }
48 :
49 : if (IS_ENABLED(CONFIG_LOG_THREAD_ID_PREFIX)) {
50 : flags |= LOG_OUTPUT_FLAG_THREAD;
51 : }
52 :
53 : return flags;
54 : }
55 :
56 : /** @brief Put a standard logger backend into panic mode.
57 : *
58 : * @param output Log output instance.
59 : */
60 : static inline void
61 1 : log_backend_std_panic(const struct log_output *const output)
62 : {
63 : log_output_flush(output);
64 : }
65 :
66 : /** @brief Report dropped messages to a standard logger backend.
67 : *
68 : * @param output Log output instance.
69 : * @param cnt Number of dropped messages.
70 : */
71 : static inline void
72 1 : log_backend_std_dropped(const struct log_output *const output, uint32_t cnt)
73 : {
74 : log_output_dropped_process(output, cnt);
75 : }
76 :
77 : /**
78 : * @}
79 : */
80 :
81 : #ifdef __cplusplus
82 : }
83 : #endif
84 :
85 : #endif /* ZEPHYR_LOG_BACKEND_STD_H_ */
|