Zephyr API Documentation 4.0.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#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_
7#define ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_
8
9#include <zephyr/kernel.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
36
42void log_core_init(void);
43
48void log_init(void);
49
55
65void log_thread_set(k_tid_t process_tid);
66
76 uint32_t freq);
77
88__syscall void log_panic(void);
89
96__syscall bool log_process(void);
97
104
112
113
121const char *log_source_name_get(uint32_t domain_id, uint32_t source_id);
122
129static inline uint8_t log_domains_count(void)
130{
131 return 1 + (IS_ENABLED(CONFIG_LOG_MULTIDOMAIN) ? z_log_ext_domain_count() : 0);
132}
133
140const char *log_domain_name_get(uint32_t domain_id);
141
149int log_source_id_get(const char *name);
150
161uint32_t log_filter_get(struct log_backend const *const backend,
162 uint32_t domain_id, int16_t source_id, bool runtime);
163
175__syscall uint32_t log_filter_set(struct log_backend const *const backend,
176 uint32_t domain_id, int16_t source_id,
177 uint32_t level);
178
187uint32_t log_frontend_filter_get(int16_t source_id, bool runtime);
188
198
207void log_backend_enable(struct log_backend const *const backend,
208 void *ctx,
209 uint32_t level);
210
217void log_backend_disable(struct log_backend const *const backend);
218
226const struct log_backend *log_backend_get_by_name(const char *backend_name);
227
234const struct log_backend *log_format_set_all_active_backends(size_t log_type);
235
245static inline bool log_data_pending(void)
246{
247 return IS_ENABLED(CONFIG_LOG_MODE_DEFERRED) ? z_log_msg_pending() : false;
248}
249
259int log_set_tag(const char *tag);
260
270int log_mem_get_usage(uint32_t *buf_size, uint32_t *usage);
271
286
287#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL)
288#define LOG_CORE_INIT() log_core_init()
289#define LOG_PANIC() log_panic()
290#if defined(CONFIG_LOG_FRONTEND_ONLY)
291#define LOG_INIT() 0
292#define LOG_PROCESS() false
293#else /* !CONFIG_LOG_FRONTEND_ONLY */
294#define LOG_INIT() log_init()
295#define LOG_PROCESS() log_process()
296#endif /* !CONFIG_LOG_FRONTEND_ONLY */
297#else
298#define LOG_CORE_INIT() do { } while (false)
299#define LOG_INIT() 0
300#define LOG_PANIC() /* Empty */
301#define LOG_PROCESS() false
302#endif
303
304#include <zephyr/syscalls/log_ctrl.h>
305
310#ifdef __cplusplus
311}
312#endif
313
314#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:129
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:245
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.
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)
Definition log_ctrl.h:35
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.
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:140
Public kernel APIs.
uint32_t log_timestamp_t
Definition log_msg.h:36
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__INT16_TYPE__ int16_t
Definition stdint.h:73
Thread Structure.
Definition thread.h:259
Logger backend structure.
Definition log_backend.h:94