Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
log_ctrl.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_LOGGING_LOG_CTRL_H_
14#define ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_
15
16#include <zephyr/kernel.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
33
41
51
57void log_core_init(void);
58
63void log_init(void);
64
70
80void log_thread_set(k_tid_t process_tid);
81
91 uint32_t freq);
92
103__syscall void log_panic(void);
104
111__syscall bool log_process(void);
112
116#ifdef CONFIG_LOG_MODE_DEFERRED
117void log_flush(void);
118#else
119static inline void log_flush(void)
120{
121}
122#endif
123
130
138
139
147const char *log_source_name_get(uint32_t domain_id, uint32_t source_id);
148
155static inline uint8_t log_domains_count(void)
156{
157 return 1 + (IS_ENABLED(CONFIG_LOG_MULTIDOMAIN) ? z_log_ext_domain_count() : 0);
158}
159
166const char *log_domain_name_get(uint32_t domain_id);
167
175int log_source_id_get(const char *name);
176
187uint32_t log_filter_get(struct log_backend const *const backend,
188 uint32_t domain_id, int16_t source_id, bool runtime);
189
201__syscall uint32_t log_filter_set(struct log_backend const *const backend,
202 uint32_t domain_id, int16_t source_id,
203 uint32_t level);
204
213uint32_t log_frontend_filter_get(int16_t source_id, bool runtime);
214
224
233void log_backend_enable(struct log_backend const *const backend,
234 void *ctx,
235 uint32_t level);
236
243void log_backend_disable(struct log_backend const *const backend);
244
252const struct log_backend *log_backend_get_by_name(const char *backend_name);
253
260const struct log_backend *log_format_set_all_active_backends(size_t log_type);
261
271static inline bool log_data_pending(void)
272{
273 return IS_ENABLED(CONFIG_LOG_MODE_DEFERRED) ? z_log_msg_pending() : false;
274}
275
285int log_set_tag(const char *tag);
286
296int log_mem_get_usage(uint32_t *buf_size, uint32_t *usage);
297
312
314#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL)
315#define LOG_CORE_INIT() log_core_init()
316#define LOG_PANIC() log_panic()
317#if defined(CONFIG_LOG_FRONTEND_ONLY)
318#define LOG_INIT() 0
319#define LOG_PROCESS() false
320#else /* !CONFIG_LOG_FRONTEND_ONLY */
321#define LOG_INIT() log_init()
322#define LOG_PROCESS() log_process()
323#endif /* !CONFIG_LOG_FRONTEND_ONLY */
324#else
325#define LOG_CORE_INIT() do { } while (false)
326#define LOG_INIT() 0
327#define LOG_PANIC() /* Empty */
328#define LOG_PROCESS() false
329#endif
331
332#include <zephyr/syscalls/log_ctrl.h>
333
337
338#ifdef __cplusplus
339}
340#endif
341
342#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_ */
int log_source_id_get(const char *name)
Function for finding source ID based on source name.
uint32_t log_src_cnt_get(uint32_t domain_id)
Get number of independent logger sources (modules and instances).
void log_thread_trigger(void)
Trigger the log processing thread to process logs immediately.
void log_init(void)
Function for user initialization of the logger.
int log_mem_get_max_usage(uint32_t *max)
Get maximum memory usage.
uint32_t log_frontend_filter_set(int16_t source_id, uint32_t level)
Set filter on given source for the frontend.
uint32_t log_filter_set(struct log_backend const *const backend, uint32_t domain_id, int16_t source_id, uint32_t level)
Set filter on given source for the provided backend.
void log_core_init(void)
Function system initialization of the logger.
static uint8_t log_domains_count(void)
Return number of domains present in the system.
Definition log_ctrl.h:155
int log_set_tag(const char *tag)
Configure tag used to prefix each message.
int log_mem_get_usage(uint32_t *buf_size, uint32_t *usage)
Get current memory usage.
void log_thread_set(k_tid_t process_tid)
Function for providing thread which is processing logs.
void log_panic(void)
Switch the logger subsystem to the panic mode.
static bool log_data_pending(void)
Check if there is pending data to be processed by the logging subsystem.
Definition log_ctrl.h:271
const char * log_source_name_get(uint32_t domain_id, uint32_t source_id)
Get name of the source (module or instance).
bool log_process(void)
Process one pending log message.
uint32_t log_frontend_filter_get(int16_t source_id, bool runtime)
Get source filter for the frontend.
uint32_t log_filter_get(struct log_backend const *const backend, uint32_t domain_id, int16_t source_id, bool runtime)
Get source filter for the provided backend.
const struct log_backend * log_backend_get_by_name(const char *backend_name)
Get backend by name.
static void log_flush(void)
Process all pending log messages.
Definition log_ctrl.h:119
uint32_t log_buffered_cnt(void)
Return number of buffered log messages.
const char * log_domain_name_get(uint32_t domain_id)
Get name of the domain.
void log_backend_enable(struct log_backend const *const backend, void *ctx, uint32_t level)
Enable backend with initial maximum filtering level.
log_timestamp_t(* log_timestamp_get_t)(void)
Timestamp source callback.
Definition log_ctrl.h:50
int log_set_timestamp_func(log_timestamp_get_t timestamp_getter, uint32_t freq)
Function for providing timestamp function.
const struct log_backend * log_format_set_all_active_backends(size_t log_type)
Sets logging format for all active backends.
void log_backend_disable(struct log_backend const *const backend)
Disable backend.
uint32_t log_timestamp_t
Timestamp value associated with a log message.
Definition log_msg.h:54
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:154
struct k_thread * k_tid_t
Definition thread.h:383
Public kernel APIs.
Header file for the logging backend interface.
Header file for logging internal functions.
Header file for log messages.
#define max(a, b)
Return larger value of two provided expressions.
Definition minmax.h:65
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__INT16_TYPE__ int16_t
Definition stdint.h:73
Logger backend structure.
Definition log_backend.h:118