Zephyr API Documentation 4.0.0-rc3
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
7#ifndef ZEPHYR_INCLUDE_SHELL_LOG_BACKEND_H_
8#define ZEPHYR_INCLUDE_SHELL_LOG_BACKEND_H_
9
10#include <zephyr/kernel.h>
14#include <zephyr/sys/atomic.h>
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19extern const struct log_backend_api log_backend_shell_api;
20
28
34
44
50
52int z_shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx);
53
69#ifdef CONFIG_SHELL_LOG_BACKEND
70#define Z_SHELL_LOG_BACKEND_DEFINE(_name, _buf, _size, _queue_size, _timeout) \
71 LOG_BACKEND_DEFINE(_name##_backend, log_backend_shell_api, false); \
72 LOG_OUTPUT_DEFINE(_name##_log_output, z_shell_log_backend_output_func,\
73 _buf, _size); \
74 static struct shell_log_backend_control_block _name##_control_block; \
75 static uint32_t __aligned(Z_LOG_MSG_ALIGNMENT) \
76 _name##_buf[_queue_size / sizeof(uint32_t)]; \
77 const struct mpsc_pbuf_buffer_config _name##_mpsc_buffer_config = { \
78 .buf = _name##_buf, \
79 .size = ARRAY_SIZE(_name##_buf), \
80 .notify_drop = NULL, \
81 .get_wlen = log_msg_generic_get_wlen, \
82 .flags = MPSC_PBUF_MODE_OVERWRITE, \
83 }; \
84 struct mpsc_pbuf_buffer _name##_mpsc_buffer; \
85 static const struct shell_log_backend _name##_log_backend = { \
86 .backend = &_name##_backend, \
87 .log_output = &_name##_log_output, \
88 .control_block = &_name##_control_block, \
89 .timeout = _timeout, \
90 .mpsc_buffer_config = &_name##_mpsc_buffer_config, \
91 .mpsc_buffer = &_name##_mpsc_buffer, \
92 }
93
94#define Z_SHELL_LOG_BACKEND_PTR(_name) (&_name##_log_backend)
95#else /* CONFIG_LOG */
96#define Z_SHELL_LOG_BACKEND_DEFINE(_name, _buf, _size, _queue_size, _timeout)
97#define Z_SHELL_LOG_BACKEND_PTR(_name) NULL
98#endif /* CONFIG_LOG */
99
106void z_shell_log_backend_enable(const struct shell_log_backend *backend,
107 void *ctx, uint32_t init_log_level);
108
113void z_shell_log_backend_disable(const struct shell_log_backend *backend);
114
121bool z_shell_log_backend_process(const struct shell_log_backend *backend);
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif /* ZEPHYR_INCLUDE_SHELL_LOG_BACKEND_H_ */
long atomic_t
Definition atomic_types.h:15
Public kernel APIs.
shell_log_backend_state
Shell log backend states.
Definition shell_log_backend.h:22
@ SHELL_LOG_BACKEND_UNINIT
Definition shell_log_backend.h:23
@ SHELL_LOG_BACKEND_PANIC
Definition shell_log_backend.h:26
@ SHELL_LOG_BACKEND_DISABLED
Definition shell_log_backend.h:25
@ SHELL_LOG_BACKEND_ENABLED
Definition shell_log_backend.h:24
const struct log_backend_api log_backend_shell_api
__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:94
Definition log_msg.h:94
uint8_t data[]
Definition log_msg.h:100
Log_output instance structure.
Definition log_output.h:96
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:30
enum shell_log_backend_state state
Definition shell_log_backend.h:32
atomic_t dropped_cnt
Definition shell_log_backend.h:31
Shell log backend message structure.
Definition shell_log_backend.h:46
struct log_msg * msg
Definition shell_log_backend.h:47
uint32_t timestamp
Definition shell_log_backend.h:48
Shell log backend instance structure (RO data).
Definition shell_log_backend.h:36
uint32_t timeout
Definition shell_log_backend.h:40
struct mpsc_pbuf_buffer * mpsc_buffer
Definition shell_log_backend.h:42
const struct log_backend * backend
Definition shell_log_backend.h:37
const struct mpsc_pbuf_buffer_config * mpsc_buffer_config
Definition shell_log_backend.h:41
const struct log_output * log_output
Definition shell_log_backend.h:38
struct shell_log_backend_control_block * control_block
Definition shell_log_backend.h:39