Zephyr Project API  3.2.0
A Scalable Open Source RTOS
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
34
40void log_core_init(void);
41
46void log_init(void);
47
57void log_thread_set(k_tid_t process_tid);
58
68 uint32_t freq);
69
80__syscall void log_panic(void);
81
88__syscall bool log_process(void);
89
95__syscall uint32_t log_buffered_cnt(void);
96
104
105
113const char *log_source_name_get(uint32_t domain_id, uint32_t source_id);
114
121const char *log_domain_name_get(uint32_t domain_id);
122
130int log_source_id_get(const char *name);
131
142uint32_t log_filter_get(struct log_backend const *const backend,
143 uint32_t domain_id, int16_t source_id, bool runtime);
144
156__syscall uint32_t log_filter_set(struct log_backend const *const backend,
157 uint32_t domain_id, int16_t source_id,
158 uint32_t level);
159
168void log_backend_enable(struct log_backend const *const backend,
169 void *ctx,
170 uint32_t level);
171
178void log_backend_disable(struct log_backend const *const backend);
179
187const struct log_backend *log_backend_get_by_name(const char *backend_name);
188
195const struct log_backend *log_format_set_all_active_backends(size_t log_type);
196
201
209
216
226static inline bool log_data_pending(void)
227{
228 return IS_ENABLED(CONFIG_LOG_MODE_DEFERRED) ? z_log_msg_pending() : false;
229}
230
240int log_set_tag(const char *tag);
241
251int log_mem_get_usage(uint32_t *buf_size, uint32_t *usage);
252
267
268#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL)
269#define LOG_CORE_INIT() log_core_init()
270#define LOG_PANIC() log_panic()
271#if defined(CONFIG_LOG_FRONTEND_ONLY)
272#define LOG_INIT() 0
273#define LOG_PROCESS() false
274#else /* !CONFIG_LOG_FRONTEND_ONLY */
275#define LOG_INIT() log_init()
276#define LOG_PROCESS() log_process()
277#endif /* !CONFIG_LOG_FRONTEND_ONLY */
278#else
279#define LOG_CORE_INIT() do { } while (false)
280#define LOG_INIT() 0
281#define LOG_PANIC() /* Empty */
282#define LOG_PROCESS() false
283#endif
284
285#include <syscalls/log_ctrl.h>
286
291#ifdef __cplusplus
292}
293#endif
294
295#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_ */
uint32_t log_get_strdup_longest_string(void)
Get length of the longest string duplicated.
int log_source_id_get(const char *name)
Function for finding source ID based on source name.
uint32_t log_get_strdup_pool_utilization(void)
Get maximal number of simultaneously allocated buffers for string duplicates.
uint32_t log_src_cnt_get(uint32_t domain_id)
Get number of independent logger sources (modules and instances)
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_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.
int log_set_tag(const char *tag)
Configure tag used to prefix each message.
uint32_t log_get_strdup_pool_current_utilization(void)
Get current number of allocated buffers for string duplicates.
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:226
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_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:33
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:101
Public kernel APIs.
uint32_t log_timestamp_t
Definition: log_msg.h:35
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__INT16_TYPE__ int16_t
Definition: stdint.h:73
Definition: thread.h:245
Logger backend structure.
Definition: log_backend.h:90
static const char * tag(void)
Definition: main.c:27