Zephyr API Documentation 4.5.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
110__syscall void log_panic(void);
111
126
133__syscall bool log_process(void);
134
138#ifdef CONFIG_LOG_MODE_DEFERRED
139void log_flush(void);
140#else
141static inline void log_flush(void)
142{
143}
144#endif
145
152
160
161
169const char *log_source_name_get(uint32_t domain_id, uint32_t source_id);
170
177static inline uint8_t log_domains_count(void)
178{
179 return 1 + (IS_ENABLED(CONFIG_LOG_MULTIDOMAIN) ? z_log_ext_domain_count() : 0);
180}
181
188const char *log_domain_name_get(uint32_t domain_id);
189
197int log_source_id_get(const char *name);
198
209uint32_t log_filter_get(struct log_backend const *const backend,
210 uint32_t domain_id, int16_t source_id, bool runtime);
211
223__syscall uint32_t log_filter_set(struct log_backend const *const backend,
224 uint32_t domain_id, int16_t source_id,
225 uint32_t level);
226
235uint32_t log_frontend_filter_get(int16_t source_id, bool runtime);
236
246
255void log_backend_enable(struct log_backend const *const backend,
256 void *ctx,
257 uint32_t level);
258
265void log_backend_disable(struct log_backend const *const backend);
266
274const struct log_backend *log_backend_get_by_name(const char *backend_name);
275
282const struct log_backend *log_format_set_all_active_backends(size_t log_type);
283
293static inline bool log_data_pending(void)
294{
295 return IS_ENABLED(CONFIG_LOG_MODE_DEFERRED) ? z_log_msg_pending() : false;
296}
297
307int log_set_tag(const char *tag);
308
318int log_mem_get_usage(uint32_t *buf_size, uint32_t *usage);
319
334
336#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL)
337#define LOG_CORE_INIT() log_core_init()
338#define LOG_PANIC() log_panic()
339#define LOG_PANIC_PREPARE() log_panic_prepare()
340#if defined(CONFIG_LOG_FRONTEND_ONLY)
341#define LOG_INIT() 0
342#define LOG_PROCESS() false
343#else /* !CONFIG_LOG_FRONTEND_ONLY */
344#define LOG_INIT() log_init()
345#define LOG_PROCESS() log_process()
346#endif /* !CONFIG_LOG_FRONTEND_ONLY */
347#else
348#define LOG_CORE_INIT() do { } while (false)
349#define LOG_INIT() 0
350#define LOG_PANIC() /* Empty */
351#define LOG_PANIC_PREPARE() /* Empty */
352#define LOG_PROCESS() false
353#endif
355
356#include <zephyr/syscalls/log_ctrl.h>
357
361
362#ifdef __cplusplus
363}
364#endif
365
366#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:177
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_prepare(void)
Stop the processing of log messages ahead of log_panic().
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:293
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:141
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:166
struct k_thread * k_tid_t
Definition thread.h:414
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:129