forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_ctrl.h
189 lines (164 loc) · 4.39 KB
/
log_ctrl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* Copyright (c) 2018 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_
#define ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_
#include <logging/log_backend.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Logger
* @defgroup logger Logger system
* @ingroup logging
* @{
* @}
*/
/**
* @brief Logger control API
* @defgroup log_ctrl Logger control API
* @ingroup logger
* @{
*/
typedef u32_t (*timestamp_get_t)(void);
/** @brief Function system initialization of the logger.
*
* Function is called during start up to allow logging before user can
* explicitly initialize the logger.
*/
void log_core_init(void);
/**
* @brief Function for user initialization of the logger.
*
*/
void log_init(void);
/**
* @brief Function for providing thread which is processing logs.
*
* See CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD.
*
* @note Function has asserts and has no effect when CONFIG_LOG_PROCESS_THREAD is set.
*
* @param process_tid Process thread id. Used to wake up the thread.
*/
void log_thread_set(k_tid_t process_tid);
/**
* @brief Function for providing timestamp function.
*
* @param timestamp_getter Timestamp function.
* @param freq Timestamping frequency.
*
* @return 0 on success or error.
*/
int log_set_timestamp_func(timestamp_get_t timestamp_getter, u32_t freq);
/**
* @brief Switch the logger subsystem to the panic mode.
*
* Returns immediately if the logger is already in the panic mode.
*
* @details On panic the logger subsystem informs all backends about panic mode.
* Backends must switch to blocking mode or halt. All pending logs
* are flushed after switching to panic mode. In panic mode, all log
* messages must be processed in the context of the call.
*/
void log_panic(void);
/**
* @brief Process one pending log message.
*
* @param bypass If true message is released without being processed.
*
* @retval true There is more messages pending to be processed.
* @retval false No messages pending.
*/
bool log_process(bool bypass);
/**
* @brief Return number of buffered log messages.
*
* @return Number of currently buffered log messages.
*/
u32_t log_buffered_cnt(void);
/** @brief Get number of independent logger sources (modules and instances)
*
* @param domain_id Domain ID.
*
* @return Number of sources.
*/
u32_t log_src_cnt_get(u32_t domain_id);
/** @brief Get name of the source (module or instance).
*
* @param domain_id Domain ID.
* @param src_id Source ID.
*
* @return Source name or NULL if invalid arguments.
*/
const char *log_source_name_get(u32_t domain_id, u32_t src_id);
/** @brief Get name of the domain.
*
* @param domain_id Domain ID.
*
* @return Domain name.
*/
const char *log_domain_name_get(u32_t domain_id);
/**
* @brief Get source filter for the provided backend.
*
* @param backend Backend instance.
* @param domain_id ID of the domain.
* @param src_id Source (module or instance) ID.
* @param runtime True for runtime filter or false for compiled in.
*
* @return Severity level.
*/
u32_t log_filter_get(struct log_backend const *const backend,
u32_t domain_id, u32_t src_id, bool runtime);
/**
* @brief Set filter on given source for the provided backend.
*
* @param backend Backend instance. NULL for all backends.
* @param domain_id ID of the domain.
* @param src_id Source (module or instance) ID.
* @param level Severity level.
*
* @return Actual level set which may be limited by compiled level. If filter
* was set for all backends then maximal level that was set is returned.
*/
u32_t log_filter_set(struct log_backend const *const backend,
u32_t domain_id,
u32_t src_id,
u32_t level);
/**
*
* @brief Enable backend with initial maximum filtering level.
*
* @param backend Backend instance.
* @param ctx User context.
* @param level Severity level.
*/
void log_backend_enable(struct log_backend const *const backend,
void *ctx,
u32_t level);
/**
*
* @brief Disable backend.
*
* @param backend Backend instance.
*/
void log_backend_disable(struct log_backend const *const backend);
#if CONFIG_LOG
#define LOG_INIT() log_init()
#define LOG_PANIC() log_panic()
#define LOG_PROCESS() log_process(false)
#else
#define LOG_INIT() 0
#define LOG_PANIC() /* Empty */
#define LOG_PROCESS() false
#endif
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_ */