Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
shell_log_backend.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_SHELL_LOG_BACKEND_H_
14#define ZEPHYR_INCLUDE_SHELL_LOG_BACKEND_H_
15
16#include <zephyr/kernel.h>
20#include <zephyr/sys/atomic.h>
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25extern const struct log_backend_api log_backend_shell_api;
26
34
40
50
56
58int z_shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx);
59
75#ifdef CONFIG_SHELL_LOG_BACKEND
76#define Z_SHELL_LOG_BACKEND_DEFINE(_name, _buf, _size, _queue_size, _timeout) \
77 LOG_BACKEND_DEFINE(_name##_backend, log_backend_shell_api, false); \
78 LOG_OUTPUT_DEFINE(_name##_log_output, z_shell_log_backend_output_func,\
79 _buf, _size); \
80 static struct shell_log_backend_control_block _name##_control_block; \
81 static uint32_t __aligned(Z_LOG_MSG_ALIGNMENT) \
82 _name##_buf[_queue_size / sizeof(uint32_t)]; \
83 const struct mpsc_pbuf_buffer_config _name##_mpsc_buffer_config = { \
84 .buf = _name##_buf, \
85 .size = ARRAY_SIZE(_name##_buf), \
86 .notify_drop = NULL, \
87 .get_wlen = log_msg_generic_get_wlen, \
88 .flags = MPSC_PBUF_MODE_OVERWRITE, \
89 }; \
90 struct mpsc_pbuf_buffer _name##_mpsc_buffer; \
91 static const struct shell_log_backend _name##_log_backend = { \
92 .backend = &_name##_backend, \
93 .log_output = &_name##_log_output, \
94 .control_block = &_name##_control_block, \
95 .timeout = _timeout, \
96 .mpsc_buffer_config = &_name##_mpsc_buffer_config, \
97 .mpsc_buffer = &_name##_mpsc_buffer, \
98 }
99
100#define Z_SHELL_LOG_BACKEND_PTR(_name) (&_name##_log_backend)
101#else /* CONFIG_LOG */
102#define Z_SHELL_LOG_BACKEND_DEFINE(_name, _buf, _size, _queue_size, _timeout)
103#define Z_SHELL_LOG_BACKEND_PTR(_name) NULL
104#endif /* CONFIG_LOG */
105
112void z_shell_log_backend_enable(const struct shell_log_backend *backend,
113 void *ctx, uint32_t init_log_level);
114
119void z_shell_log_backend_disable(const struct shell_log_backend *backend);
120
127bool z_shell_log_backend_process(const struct shell_log_backend *backend);
128
129#ifdef __cplusplus
130}
131#endif
132
133#endif /* ZEPHYR_INCLUDE_SHELL_LOG_BACKEND_H_ */
long atomic_t
Definition atomic_types.h:15
const struct log_backend_api log_backend_shell_api
Public kernel APIs.
shell_log_backend_state
Shell log backend states.
Definition shell_log_backend.h:28
@ SHELL_LOG_BACKEND_UNINIT
Definition shell_log_backend.h:29
@ SHELL_LOG_BACKEND_PANIC
Definition shell_log_backend.h:32
@ SHELL_LOG_BACKEND_DISABLED
Definition shell_log_backend.h:31
@ SHELL_LOG_BACKEND_ENABLED
Definition shell_log_backend.h:30
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Logger backend API.
Definition log_backend.h:63
Logger backend structure.
Definition log_backend.h:95
Definition log_msg.h:97
uint8_t data[]
Definition log_msg.h:103
MPSC packet buffer configuration.
Definition mpsc_pbuf.h:131
MPSC packet buffer structure.
Definition mpsc_pbuf.h:90
Shell log backend control block (RW data).
Definition shell_log_backend.h:36
enum shell_log_backend_state state
Definition shell_log_backend.h:38
atomic_t dropped_cnt
Definition shell_log_backend.h:37
Shell log backend message structure.
Definition shell_log_backend.h:52
struct log_msg * msg
Definition shell_log_backend.h:53
uint32_t timestamp
Definition shell_log_backend.h:54
Shell log backend instance structure (RO data).
Definition shell_log_backend.h:42
uint32_t timeout
Definition shell_log_backend.h:46
struct mpsc_pbuf_buffer * mpsc_buffer
Definition shell_log_backend.h:48
const struct log_backend * backend
Definition shell_log_backend.h:43
const struct mpsc_pbuf_buffer_config * mpsc_buffer_config
Definition shell_log_backend.h:47
const struct log_output * log_output
Definition shell_log_backend.h:44
struct shell_log_backend_control_block * control_block
Definition shell_log_backend.h:45