Zephyr Project API 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

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_backendlog_backend_get_by_name (const char *backend_name)
 Get backend by name.
 
const struct log_backendlog_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.
 

Detailed Description

Logger control API.

Since
1.13

Macro Definition Documentation

◆ LOG_CORE_INIT

#define LOG_CORE_INIT ( )    do { } while (false)

◆ LOG_INIT

#define LOG_INIT ( )    0

◆ LOG_PANIC

#define LOG_PANIC ( )    /* Empty */

◆ LOG_PROCESS

#define LOG_PROCESS ( )    false

Typedef Documentation

◆ log_timestamp_get_t

typedef log_timestamp_t(* log_timestamp_get_t) (void)

Function Documentation

◆ log_backend_disable()

void log_backend_disable ( struct log_backend const *const  backend)

#include <include/zephyr/logging/log_ctrl.h>

Disable backend.

Parameters
backendBackend instance.

◆ log_backend_enable()

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.

Parameters
backendBackend instance.
ctxUser context.
levelSeverity level.

◆ log_backend_get_by_name()

const struct log_backend * log_backend_get_by_name ( const char *  backend_name)

#include <include/zephyr/logging/log_ctrl.h>

Get backend by name.

Parameters
[in]backend_nameName of the backend as defined by the LOG_BACKEND_DEFINE.
Return values
Pointerto the backend instance if found, NULL if backend is not found.

◆ log_buffered_cnt()

uint32_t log_buffered_cnt ( void  )

#include <include/zephyr/logging/log_ctrl.h>

Return number of buffered log messages.

Returns
Number of currently buffered log messages.

◆ log_core_init()

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.

◆ log_data_pending()

static bool log_data_pending ( void  )
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.

Return values
trueThere is pending data.
falseNo pending data to process.

◆ log_domain_name_get()

const char * log_domain_name_get ( uint32_t  domain_id)

#include <include/zephyr/logging/log_ctrl.h>

Get name of the domain.

Parameters
domain_idDomain ID.
Returns
Domain name.

◆ log_domains_count()

static uint8_t log_domains_count ( void  )
inlinestatic

#include <include/zephyr/logging/log_ctrl.h>

Return number of domains present in the system.

There will be at least one local domain.

Returns
Number of domains.

◆ log_filter_get()

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.

Parameters
backendBackend instance.
domain_idID of the domain.
source_idSource (module or instance) ID.
runtimeTrue for runtime filter or false for compiled in.
Returns
Severity level.

◆ log_filter_set()

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.

Parameters
backendBackend instance. NULL for all backends (and frontend).
domain_idID of the domain.
source_idSource (module or instance) ID.
levelSeverity level.
Returns
Actual level set which may be limited by compiled level. If filter was set for all backends then maximal level that was set is returned.

◆ log_format_set_all_active_backends()

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.

Parameters
log_typeLog format.
Return values
Pointerto the last backend that failed, NULL for success.

◆ log_frontend_filter_get()

uint32_t log_frontend_filter_get ( int16_t  source_id,
bool  runtime 
)

#include <include/zephyr/logging/log_ctrl.h>

Get source filter for the frontend.

Parameters
source_idSource (module or instance) ID.
runtimeTrue for runtime filter or false for compiled in.
Returns
Severity level.

◆ log_frontend_filter_set()

uint32_t log_frontend_filter_set ( int16_t  source_id,
uint32_t  level 
)

#include <include/zephyr/logging/log_ctrl.h>

Set filter on given source for the frontend.

Parameters
source_idSource (module or instance) ID.
levelSeverity level.
Returns
Actual level set which may be limited by compiled level.

◆ log_init()

void log_init ( void  )

#include <include/zephyr/logging/log_ctrl.h>

Function for user initialization of the logger.

◆ log_mem_get_max_usage()

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.

Parameters
[out]maxMaximum number of bytes used for pending log messages.
Return values
-EINVALif logging mode does not use the buffer.
-ENOTSUPif instrumentation is not enabled. not been enabled.
0successfully collected usage data.

◆ log_mem_get_usage()

int log_mem_get_usage ( uint32_t buf_size,
uint32_t usage 
)

#include <include/zephyr/logging/log_ctrl.h>

Get current memory usage.

Parameters
[out]buf_sizeCapacity of the buffer used for storing log messages.
[out]usageNumber of bytes currently containing pending log messages.
Return values
-EINVALif logging mode does not use the buffer.
0successfully collected usage data.

◆ log_panic()

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.

◆ log_process()

bool log_process ( void  )

#include <include/zephyr/logging/log_ctrl.h>

Process one pending log message.

Return values
trueThere are more messages pending to be processed.
falseNo messages pending.

◆ log_set_tag()

int log_set_tag ( const char *  tag)

#include <include/zephyr/logging/log_ctrl.h>

Configure tag used to prefix each message.

Parameters
tagTag.
Return values
0on successful operation.
-ENOTSUPif feature is disabled.
-ENOMEMif string is longer than the buffer capacity. Tag will be trimmed.

◆ log_set_timestamp_func()

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.

Parameters
timestamp_getterTimestamp function.
freqTimestamping frequency.
Returns
0 on success or error.

◆ log_source_id_get()

int log_source_id_get ( const char *  name)

#include <include/zephyr/logging/log_ctrl.h>

Function for finding source ID based on source name.

Parameters
nameSource name
Returns
Source ID or negative number when source ID is not found.

◆ log_source_name_get()

const char * log_source_name_get ( uint32_t  domain_id,
uint32_t  source_id 
)

#include <include/zephyr/logging/log_ctrl.h>

Get name of the source (module or instance).

Parameters
domain_idDomain ID.
source_idSource ID.
Returns
Source name or NULL if invalid arguments.

◆ log_src_cnt_get()

uint32_t log_src_cnt_get ( uint32_t  domain_id)

#include <include/zephyr/logging/log_ctrl.h>

Get number of independent logger sources (modules and instances)

Parameters
domain_idDomain ID.
Returns
Number of sources.

◆ log_thread_set()

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.

Note
Function has asserts and has no effect when CONFIG_LOG_PROCESS_THREAD is set.
Parameters
process_tidProcess thread id. Used to wake up the thread.

◆ log_thread_trigger()

void log_thread_trigger ( void  )

#include <include/zephyr/logging/log_ctrl.h>

Trigger the log processing thread to process logs immediately.

Note
Function has no effect when CONFIG_LOG_MODE_IMMEDIATE is set.