Zephyr Project API  3.1.0
A Scalable Open Source RTOS
log_backend_std.h
Go to the documentation of this file.
1/*
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
11#include <zephyr/kernel.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
25{
27
28 if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
30 }
31
32 if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
34 }
35
36 return flags;
37}
38
45static inline void
46log_backend_std_put(const struct log_output *const output, uint32_t flags,
47 struct log_msg *msg)
48{
50
52
54
56}
57
62static inline void
63log_backend_std_panic(const struct log_output *const output)
64{
65 log_output_flush(output);
66}
67
73static inline void
74log_backend_std_dropped(const struct log_output *const output, uint32_t cnt)
75{
76 log_output_dropped_process(output, cnt);
77}
78
88static inline void
89log_backend_std_sync_string(const struct log_output *const output,
90 uint32_t flags, struct log_msg_ids src_level,
91 uint32_t timestamp, const char *fmt, va_list ap)
92{
93 int key;
94
96 if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
98 }
99
100 if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
102 }
103
104 if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
105 /* In order to ensure that one log processing is not interrupted
106 * by another one, lock context for whole log processing.
107 */
108 key = irq_lock();
109 }
110
111 log_output_string(output, src_level, timestamp, fmt, ap, flags);
112
113 if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
115 }
116}
117
128static inline void
129log_backend_std_sync_hexdump(const struct log_output *const output,
130 uint32_t flags, struct log_msg_ids src_level,
131 uint32_t timestamp, const char *metadata,
132 const uint8_t *data, uint32_t length)
133{
134 int key;
135
137 if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
139 }
140
141 if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
143 }
144
145 if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
146 /* In order to ensure that one log processing is not interrupted
147 * by another one, lock context for whole log processing.
148 */
149 key = irq_lock();
150 }
151
152 log_output_hexdump(output, src_level, timestamp,
153 metadata, data, length, flags);
154
155 if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
157 }
158}
159
164#ifdef __cplusplus
165}
166#endif
167
168#endif /* ZEPHYR_LOG_BACKEND_STD_H_ */
#define irq_lock()
Lock interrupts.
Definition: irq.h:225
#define irq_unlock(key)
Unlock interrupts.
Definition: irq.h:253
static void log_backend_std_sync_hexdump(const struct log_output *const output, uint32_t flags, struct log_msg_ids src_level, uint32_t timestamp, const char *metadata, const uint8_t *data, uint32_t length)
Synchronously process hexdump message by a standard logger backend.
Definition: log_backend_std.h:129
static void log_backend_std_sync_string(const struct log_output *const output, uint32_t flags, struct log_msg_ids src_level, uint32_t timestamp, const char *fmt, va_list ap)
Synchronously process log message by a standard logger backend.
Definition: log_backend_std.h:89
static uint32_t log_backend_std_get_flags(void)
Definition: log_backend_std.h:24
static void log_backend_std_put(const struct log_output *const output, uint32_t flags, struct log_msg *msg)
Put log message to a standard logger backend.
Definition: log_backend_std.h:46
static void log_backend_std_dropped(const struct log_output *const output, uint32_t cnt)
Report dropped messages to a standard logger backend.
Definition: log_backend_std.h:74
static void log_backend_std_panic(const struct log_output *const output)
Put a standard logger backend into panic mode.
Definition: log_backend_std.h:63
void log_msg_put(struct log_msg *msg)
Function for indicating that message is no longer in use.
void log_msg_get(struct log_msg *msg)
Function for indicating that message is in use.
void log_output_dropped_process(const struct log_output *output, uint32_t cnt)
Process dropped messages indication.
void log_output_flush(const struct log_output *output)
Flush output buffer.
#define LOG_OUTPUT_FLAG_LEVEL
Flag forcing severity level prefix.
Definition: log_output.h:37
void log_output_hexdump(const struct log_output *output, struct log_msg_ids src_level, uint32_t timestamp, const char *metadata, const uint8_t *data, uint32_t length, uint32_t flags)
Process log hexdump.
void log_output_msg_process(const struct log_output *output, struct log_msg *msg, uint32_t flags)
Process log messages to readable strings.
void log_output_string(const struct log_output *output, struct log_msg_ids src_level, uint32_t timestamp, const char *fmt, va_list ap, uint32_t flags)
Process log string.
#define LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP
Flag forcing timestamp formatting.
Definition: log_output.h:34
#define LOG_OUTPUT_FLAG_TIMESTAMP
Flag forcing timestamp.
Definition: log_output.h:31
#define LOG_OUTPUT_FLAG_COLORS
Flag forcing ANSI escape code colors, red (errors), yellow (warnings).
Definition: log_output.h:28
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:101
flags
Definition: http_parser.h:131
Public kernel APIs.
static k_spinlock_key_t key
Definition: spinlock_error_case.c:14
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Part of log message header identifying source and level.
Definition: log_msg.h:85
Log message structure.
Definition: log_msg.h:139
Log_output instance structure.
Definition: log_output.h:86
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
static void msg(uint64_t c64)
Definition: main.c:17