Zephyr Project API  3.1.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
90__syscall bool log_process(bool bypass);
91
97__syscall uint32_t log_buffered_cnt(void);
98
106
107
115const char *log_source_name_get(uint32_t domain_id, uint32_t source_id);
116
123const char *log_domain_name_get(uint32_t domain_id);
124
135uint32_t log_filter_get(struct log_backend const *const backend,
136 uint32_t domain_id, int16_t source_id, bool runtime);
137
149__syscall uint32_t log_filter_set(struct log_backend const *const backend,
150 uint32_t domain_id, int16_t source_id,
151 uint32_t level);
152
161void log_backend_enable(struct log_backend const *const backend,
162 void *ctx,
163 uint32_t level);
164
171void log_backend_disable(struct log_backend const *const backend);
172
180const struct log_backend *log_backend_get_by_name(const char *backend_name);
181
188const struct log_backend *log_format_set_all_active_backends(size_t log_type);
189
194
202
209
219static inline bool log_data_pending(void)
220{
221 if (IS_ENABLED(CONFIG_LOG_MODE_DEFERRED)) {
222 return IS_ENABLED(CONFIG_LOG2) ?
223 z_log_msg2_pending() : (log_msg_mem_get_used() > 0);
224 }
225
226 return false;
227}
228
238int log_set_tag(const char *tag);
239
249int log_mem_get_usage(uint32_t *buf_size, uint32_t *usage);
250
265
266#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL)
267#define LOG_CORE_INIT() log_core_init()
268#define LOG_PANIC() log_panic()
269#if defined(CONFIG_LOG_FRONTEND_ONLY)
270#define LOG_INIT() 0
271#define LOG_PROCESS() false
272#else /* !CONFIG_LOG_FRONTEND_ONLY */
273#define LOG_INIT() log_init()
274#define LOG_PROCESS() log_process(false)
275#endif /* !CONFIG_LOG_FRONTEND_ONLY */
276#else
277#define LOG_CORE_INIT() do { } while (false)
278#define LOG_INIT() 0
279#define LOG_PANIC() /* Empty */
280#define LOG_PROCESS() false
281#endif
282
283#include <syscalls/log_ctrl.h>
284
289#ifdef __cplusplus
290}
291#endif
292
293#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_CTRL_H_ */
uint32_t log_get_strdup_longest_string(void)
Get length of the longest string duplicated.
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.
bool log_process(bool bypass)
Process one pending log message.
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:219
const char * log_source_name_get(uint32_t domain_id, uint32_t source_id)
Get name of the source (module or instance).
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.
uint32_t log_msg_mem_get_used(void)
Get number of used blocks from the log mem pool.
#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_msg2.h:35
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__INT16_TYPE__ int16_t
Definition: stdint.h:73
Definition: thread.h:231
Logger backend structure.
Definition: log_backend.h:68
static const char * tag(void)
Definition: main.c:27