Zephyr Project API 4.0.0
A Scalable Open Source RTOS
|
Logger control API. More...
Macros | |
#define | LOG_CORE_INIT() do { } while (false) |
#define | LOG_INIT() 0 |
#define | LOG_PANIC() /* Empty */ |
#define | LOG_PROCESS() false |
Typedefs | |
typedef log_timestamp_t(* | log_timestamp_get_t) (void) |
Functions | |
void | log_core_init (void) |
Function system initialization of the logger. | |
void | log_init (void) |
Function for user initialization of the logger. | |
void | log_thread_trigger (void) |
Trigger the log processing thread to process logs immediately. | |
void | log_thread_set (k_tid_t process_tid) |
Function for providing thread which is processing logs. | |
int | log_set_timestamp_func (log_timestamp_get_t timestamp_getter, uint32_t freq) |
Function for providing timestamp function. | |
void | log_panic (void) |
Switch the logger subsystem to the panic mode. | |
bool | log_process (void) |
Process one pending log message. | |
uint32_t | log_buffered_cnt (void) |
Return number of buffered log messages. | |
uint32_t | log_src_cnt_get (uint32_t domain_id) |
Get number of independent logger sources (modules and instances) | |
const char * | log_source_name_get (uint32_t domain_id, uint32_t source_id) |
Get name of the source (module or instance). | |
static uint8_t | log_domains_count (void) |
Return number of domains present in the system. | |
const char * | log_domain_name_get (uint32_t domain_id) |
Get name of the domain. | |
int | log_source_id_get (const char *name) |
Function for finding source ID based on source name. | |
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. | |
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. | |
uint32_t | log_frontend_filter_get (int16_t source_id, bool runtime) |
Get source filter for the frontend. | |
uint32_t | log_frontend_filter_set (int16_t source_id, uint32_t level) |
Set filter on given source for the frontend. | |
void | log_backend_enable (struct log_backend const *const backend, void *ctx, uint32_t level) |
Enable backend with initial maximum filtering level. | |
void | log_backend_disable (struct log_backend const *const backend) |
Disable backend. | |
const struct log_backend * | log_backend_get_by_name (const char *backend_name) |
Get backend by name. | |
const struct log_backend * | log_format_set_all_active_backends (size_t log_type) |
Sets logging format for all active backends. | |
static bool | log_data_pending (void) |
Check if there is pending data to be processed by the logging subsystem. | |
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. | |
int | log_mem_get_max_usage (uint32_t *max) |
Get maximum memory usage. | |
Logger control API.
#define LOG_CORE_INIT | ( | ) | do { } while (false) |
#include <include/zephyr/logging/log_ctrl.h>
#define LOG_INIT | ( | ) | 0 |
#include <include/zephyr/logging/log_ctrl.h>
#define LOG_PANIC | ( | ) | /* Empty */ |
#include <include/zephyr/logging/log_ctrl.h>
#define LOG_PROCESS | ( | ) | false |
#include <include/zephyr/logging/log_ctrl.h>
typedef log_timestamp_t(* log_timestamp_get_t) (void) |
#include <include/zephyr/logging/log_ctrl.h>
void log_backend_disable | ( | struct log_backend const *const | backend | ) |
void log_backend_enable | ( | struct log_backend const *const | backend, |
void * | ctx, | ||
uint32_t | level | ||
) |
#include <include/zephyr/logging/log_ctrl.h>
Enable backend with initial maximum filtering level.
backend | Backend instance. |
ctx | User context. |
level | Severity level. |
const struct log_backend * log_backend_get_by_name | ( | const char * | backend_name | ) |
#include <include/zephyr/logging/log_ctrl.h>
Get backend by name.
[in] | backend_name | Name of the backend as defined by the LOG_BACKEND_DEFINE. |
Pointer | to the backend instance if found, NULL if backend is not found. |
uint32_t log_buffered_cnt | ( | void | ) |
#include <include/zephyr/logging/log_ctrl.h>
Return number of buffered log messages.
void log_core_init | ( | void | ) |
#include <include/zephyr/logging/log_ctrl.h>
Function system initialization of the logger.
Function is called during start up to allow logging before user can explicitly initialize the logger.
|
inlinestatic |
#include <include/zephyr/logging/log_ctrl.h>
Check if there is pending data to be processed by the logging subsystem.
Function can be used to determine if all logs have been flushed. Function returns false when deferred mode is not enabled.
true | There is pending data. |
false | No pending data to process. |
const char * log_domain_name_get | ( | uint32_t | domain_id | ) |
#include <include/zephyr/logging/log_ctrl.h>
Get name of the domain.
domain_id | Domain ID. |
|
inlinestatic |
#include <include/zephyr/logging/log_ctrl.h>
Return number of domains present in the system.
There will be at least one local domain.
uint32_t log_filter_get | ( | struct log_backend const *const | backend, |
uint32_t | domain_id, | ||
int16_t | source_id, | ||
bool | runtime | ||
) |
#include <include/zephyr/logging/log_ctrl.h>
Get source filter for the provided backend.
backend | Backend instance. |
domain_id | ID of the domain. |
source_id | Source (module or instance) ID. |
runtime | True for runtime filter or false for compiled in. |
uint32_t log_filter_set | ( | struct log_backend const *const | backend, |
uint32_t | domain_id, | ||
int16_t | source_id, | ||
uint32_t | level | ||
) |
#include <include/zephyr/logging/log_ctrl.h>
Set filter on given source for the provided backend.
backend | Backend instance. NULL for all backends (and frontend). |
domain_id | ID of the domain. |
source_id | Source (module or instance) ID. |
level | Severity level. |
const struct log_backend * log_format_set_all_active_backends | ( | size_t | log_type | ) |
#include <include/zephyr/logging/log_ctrl.h>
Sets logging format for all active backends.
log_type | Log format. |
Pointer | to the last backend that failed, NULL for success. |
#include <include/zephyr/logging/log_ctrl.h>
Get source filter for the frontend.
source_id | Source (module or instance) ID. |
runtime | True for runtime filter or false for compiled in. |
#include <include/zephyr/logging/log_ctrl.h>
Set filter on given source for the frontend.
source_id | Source (module or instance) ID. |
level | Severity level. |
void log_init | ( | void | ) |
#include <include/zephyr/logging/log_ctrl.h>
Function for user initialization of the logger.
int log_mem_get_max_usage | ( | uint32_t * | max | ) |
#include <include/zephyr/logging/log_ctrl.h>
Get maximum memory usage.
Requires CONFIG_LOG_MEM_UTILIZATION option.
[out] | max | Maximum number of bytes used for pending log messages. |
-EINVAL | if logging mode does not use the buffer. |
-ENOTSUP | if instrumentation is not enabled. not been enabled. |
0 | successfully collected usage data. |
#include <include/zephyr/logging/log_ctrl.h>
Get current memory usage.
[out] | buf_size | Capacity of the buffer used for storing log messages. |
[out] | usage | Number of bytes currently containing pending log messages. |
-EINVAL | if logging mode does not use the buffer. |
0 | successfully collected usage data. |
void log_panic | ( | void | ) |
#include <include/zephyr/logging/log_ctrl.h>
Switch the logger subsystem to the panic mode.
Returns immediately if the logger is already in the panic mode.
On panic the logger subsystem informs all backends about panic mode. Backends must switch to blocking mode or halt. All pending logs are flushed after switching to panic mode. In panic mode, all log messages must be processed in the context of the call.
bool log_process | ( | void | ) |
#include <include/zephyr/logging/log_ctrl.h>
Process one pending log message.
true | There are more messages pending to be processed. |
false | No messages pending. |
int log_set_tag | ( | const char * | tag | ) |
#include <include/zephyr/logging/log_ctrl.h>
Configure tag used to prefix each message.
tag | Tag. |
0 | on successful operation. |
-ENOTSUP | if feature is disabled. |
-ENOMEM | if string is longer than the buffer capacity. Tag will be trimmed. |
int log_set_timestamp_func | ( | log_timestamp_get_t | timestamp_getter, |
uint32_t | freq | ||
) |
#include <include/zephyr/logging/log_ctrl.h>
Function for providing timestamp function.
timestamp_getter | Timestamp function. |
freq | Timestamping frequency. |
int log_source_id_get | ( | const char * | name | ) |
#include <include/zephyr/logging/log_ctrl.h>
Function for finding source ID based on source name.
name | Source name |
#include <include/zephyr/logging/log_ctrl.h>
Get name of the source (module or instance).
domain_id | Domain ID. |
source_id | Source ID. |
#include <include/zephyr/logging/log_ctrl.h>
Get number of independent logger sources (modules and instances)
domain_id | Domain ID. |
void log_thread_set | ( | k_tid_t | process_tid | ) |
#include <include/zephyr/logging/log_ctrl.h>
Function for providing thread which is processing logs.
See CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD.
process_tid | Process thread id. Used to wake up the thread. |
void log_thread_trigger | ( | void | ) |
#include <include/zephyr/logging/log_ctrl.h>
Trigger the log processing thread to process logs immediately.