Zephyr API Documentation  2.7.0-rc2
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
9#include <logging/log_msg.h>
10#include <logging/log_output.h>
11#include <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{
49 log_msg_get(msg);
50
52
53 log_output_msg_process(output, msg, flags);
54
55 log_msg_put(msg);
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) &&
105 IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
106 /* In order to ensure that one log processing is not interrupted
107 * by another one, lock context for whole log processing.
108 */
109 key = irq_lock();
110 }
111
112 log_output_string(output, src_level, timestamp, fmt, ap, flags);
113
114 if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) &&
115 IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
117 }
118}
119
130static inline void
131log_backend_std_sync_hexdump(const struct log_output *const output,
132 uint32_t flags, struct log_msg_ids src_level,
133 uint32_t timestamp, const char *metadata,
134 const uint8_t *data, uint32_t length)
135{
136 int key;
137
139 if (IS_ENABLED(CONFIG_LOG_BACKEND_SHOW_COLOR)) {
141 }
142
143 if (IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)) {
145 }
146
147 if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) &&
148 IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
149 /* In order to ensure that one log processing is not interrupted
150 * by another one, lock context for whole log processing.
151 */
152 key = irq_lock();
153 }
154
155 log_output_hexdump(output, src_level, timestamp,
156 metadata, data, length, flags);
157
158 if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) &&
159 IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
161 }
162}
163
168#ifdef __cplusplus
169}
170#endif
171
172#endif /* ZEPHYR_LOG_BACKEND_STD_H_ */
#define irq_lock()
Lock interrupts.
Definition: irq.h:225
#define irq_unlock(key)
Unlock interrupts.
Definition: irq.h:255
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:131
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
static k_spinlock_key_t key
Definition: spinlock_error_case.c:14
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
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:76
static fdata_t data[2]
Definition: test_fifo_contexts.c:15