Lines Matching full:backend
21 * @brief Logger backend interface
22 * @defgroup log_backend Logger backend interface
32 * @brief Backend events
48 /** @brief Maximum number of backend events */
53 * @brief Argument(s) for backend events.
61 * @brief Logger backend API.
64 void (*process)(const struct log_backend *const backend,
67 void (*dropped)(const struct log_backend *const backend, uint32_t cnt);
68 void (*panic)(const struct log_backend *const backend);
69 void (*init)(const struct log_backend *const backend);
70 int (*is_ready)(const struct log_backend *const backend);
71 int (*format_set)(const struct log_backend *const backend,
74 void (*notify)(const struct log_backend *const backend,
80 * @brief Logger backend control block.
92 * @brief Logger backend structure.
102 * @brief Macro for creating a logger backend instance.
104 * @param _name Name of the backend instance.
105 * @param _api Logger backend API.
106 * @param _autostart If true backend is initialized and activated together
128 * @brief Initialize or initiate the logging backend.
130 * If backend initialization takes longer time it could block logging thread
131 * if backend is autostarted. That is because all backends are initialized in
132 * the context of the logging thread. In that case, backend shall provide
135 * @param[in] backend Pointer to the backend instance.
137 static inline void log_backend_init(const struct log_backend *const backend) in log_backend_init() argument
139 __ASSERT_NO_MSG(backend != NULL); in log_backend_init()
140 if (backend->api->init) { in log_backend_init()
141 backend->api->init(backend); in log_backend_init()
146 * @brief Poll for backend readiness.
148 * If backend is ready immediately after initialization then backend may not
151 * @param[in] backend Pointer to the backend instance.
153 * @retval 0 if backend is ready.
154 * @retval -EBUSY if backend is not yet ready.
156 static inline int log_backend_is_ready(const struct log_backend *const backend) in log_backend_is_ready() argument
158 __ASSERT_NO_MSG(backend != NULL); in log_backend_is_ready()
159 if (backend->api->is_ready != NULL) { in log_backend_is_ready()
160 return backend->api->is_ready(backend); in log_backend_is_ready()
170 * is processed by the backend and memory can be freed.
172 * @param[in] backend Pointer to the backend instance.
175 static inline void log_backend_msg_process(const struct log_backend *const backend, in log_backend_msg_process() argument
178 __ASSERT_NO_MSG(backend != NULL); in log_backend_msg_process()
180 backend->api->process(backend, msg); in log_backend_msg_process()
184 * @brief Notify backend about dropped log messages.
188 * @param[in] backend Pointer to the backend instance.
191 static inline void log_backend_dropped(const struct log_backend *const backend, in log_backend_dropped() argument
194 __ASSERT_NO_MSG(backend != NULL); in log_backend_dropped()
196 if (backend->api->dropped != NULL) { in log_backend_dropped()
197 backend->api->dropped(backend, cnt); in log_backend_dropped()
202 * @brief Reconfigure backend to panic mode.
204 * @param[in] backend Pointer to the backend instance.
206 static inline void log_backend_panic(const struct log_backend *const backend) in log_backend_panic() argument
208 __ASSERT_NO_MSG(backend != NULL); in log_backend_panic()
209 backend->api->panic(backend); in log_backend_panic()
213 * @brief Set backend id.
217 * @param backend Pointer to the backend instance.
220 static inline void log_backend_id_set(const struct log_backend *const backend, in log_backend_id_set() argument
223 __ASSERT_NO_MSG(backend != NULL); in log_backend_id_set()
224 backend->cb->id = id; in log_backend_id_set()
228 * @brief Get backend id.
232 * @param[in] backend Pointer to the backend instance.
235 static inline uint8_t log_backend_id_get(const struct log_backend *const backend) in log_backend_id_get() argument
237 __ASSERT_NO_MSG(backend != NULL); in log_backend_id_get()
238 return backend->cb->id; in log_backend_id_get()
242 * @brief Get backend.
244 * @param[in] idx Pointer to the backend instance.
246 * @return Pointer to the backend instance.
250 const struct log_backend *backend; in log_backend_get() local
252 STRUCT_SECTION_GET(log_backend, idx, &backend); in log_backend_get()
254 return backend; in log_backend_get()
272 * @brief Activate backend.
274 * @param[in] backend Pointer to the backend instance.
277 static inline void log_backend_activate(const struct log_backend *const backend, in log_backend_activate() argument
280 __ASSERT_NO_MSG(backend != NULL); in log_backend_activate()
281 backend->cb->ctx = ctx; in log_backend_activate()
282 backend->cb->active = true; in log_backend_activate()
286 * @brief Deactivate backend.
288 * @param[in] backend Pointer to the backend instance.
291 const struct log_backend *const backend) in log_backend_deactivate() argument
293 __ASSERT_NO_MSG(backend != NULL); in log_backend_deactivate()
294 backend->cb->active = false; in log_backend_deactivate()
298 * @brief Check state of the backend.
300 * @param[in] backend Pointer to the backend instance.
302 * @return True if backend is active, false otherwise.
305 const struct log_backend *const backend) in log_backend_is_active() argument
307 __ASSERT_NO_MSG(backend != NULL); in log_backend_is_active()
308 return backend->cb->active; in log_backend_is_active()
313 * @param backend Pointer to the backend instance.
316 * @retval -ENOTSUP If the backend does not support changing format types.
320 static inline int log_backend_format_set(const struct log_backend *backend, uint32_t log_type) in log_backend_format_set() argument
332 if (backend == NULL) { in log_backend_format_set()
336 if (backend->api->format_set == NULL) { in log_backend_format_set()
340 return backend->api->format_set(backend, log_type); in log_backend_format_set()
344 * @brief Notify a backend of an event.
346 * @param backend Pointer to the backend instance.
350 static inline void log_backend_notify(const struct log_backend *const backend, in log_backend_notify() argument
354 __ASSERT_NO_MSG(backend != NULL); in log_backend_notify()
356 if (backend->api->notify) { in log_backend_notify()
357 backend->api->notify(backend, event, arg); in log_backend_notify()