nRF5 SDK v15.2.0
Macros | Typedefs | Functions
Functions for controlling nrf_log

The nrf_log control interface. More...

Macros

#define NRF_LOG_INIT(...)   NRF_LOG_INTERNAL_INIT(__VA_ARGS__)
 Macro for initializing the logs. More...
 
#define NRF_LOG_PROCESS()   NRF_LOG_INTERNAL_PROCESS()
 Macro for processing a single log entry from a queue of deferred logs. More...
 
#define NRF_LOG_FLUSH()   NRF_LOG_INTERNAL_FLUSH()
 Macro for processing all log entries from the buffer. It blocks until all buffered entries are processed by the backend. More...
 
#define NRF_LOG_FINAL_FLUSH()   NRF_LOG_INTERNAL_FINAL_FLUSH()
 Macro for flushing log data before reset. More...
 

Typedefs

typedef uint32_t(* nrf_log_timestamp_func_t )(void)
 Timestamp function prototype. More...
 

Functions

ret_code_t nrf_log_init (nrf_log_timestamp_func_t timestamp_func, uint32_t timestamp_freq)
 Function for initializing the frontend and the default backend. More...
 
int32_t nrf_log_backend_add (nrf_log_backend_t const *p_backend, nrf_log_severity_t severity)
 Function for adding new backend interface to the logger. More...
 
void nrf_log_backend_remove (nrf_log_backend_t const *p_backend)
 Function for removing backend from the logger. More...
 
void nrf_log_panic (void)
 Function for setting logger backends into panic mode. More...
 
bool nrf_log_frontend_dequeue (void)
 Function for handling a single log entry. More...
 
uint32_t nrf_log_module_cnt_get (void)
 Function for getting number of independent log modules registered into the logger. More...
 
const char * nrf_log_module_name_get (uint32_t module_id, bool is_ordered_idx)
 Function for getting module name. More...
 
uint8_t nrf_log_color_id_get (uint32_t module_id, nrf_log_severity_t severity)
 Function for getting coloring of specific logs. More...
 
void nrf_log_module_filter_set (uint32_t backend_id, uint32_t module_id, nrf_log_severity_t severity)
 Function for configuring filtering ofs logs in the module. More...
 
nrf_log_severity_t nrf_log_module_filter_get (uint32_t backend_id, uint32_t module_id, bool is_ordered_idx, bool dynamic)
 Function for getting module severity level. More...
 
ret_code_t nrf_log_config_store (void)
 Function stores current filtering configuration into non-volatile memory using Flash Data Storage module. More...
 
ret_code_t nrf_log_config_load (void)
 Function loads configuration from non-volatile memory using Flash Data Storage module. More...
 

Detailed Description

The nrf_log control interface.

Macro Definition Documentation

#define NRF_LOG_FINAL_FLUSH ( )    NRF_LOG_INTERNAL_FINAL_FLUSH()

Macro for flushing log data before reset.

Note
If logs are not deferred, this call has no use and is empty.
If RTT is used, then a breakpoint is hit once flushed.
#define NRF_LOG_FLUSH ( )    NRF_LOG_INTERNAL_FLUSH()

Macro for processing all log entries from the buffer. It blocks until all buffered entries are processed by the backend.

Note
If logs are not deferred, this call has no use and is empty.
#define NRF_LOG_INIT (   ...)    NRF_LOG_INTERNAL_INIT(__VA_ARGS__)

Macro for initializing the logs.

Macro has one or two parameters. First parameter (obligatory) is the timestamp function (nrf_log_timestamp_func_t). Additionally, as the second parameter timestamp frequency in Hz can be provided. If not provided then default frequency is used (NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY). Frequency is used to format timestamp prefix if NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED is set.

Returns
NRF_SUCCESS after successful initialization, otherwise an error code.
#define NRF_LOG_PROCESS ( )    NRF_LOG_INTERNAL_PROCESS()

Macro for processing a single log entry from a queue of deferred logs.

You can call this macro from the main context or from the error handler to process log entries one by one.

Note
If logs are not deferred, this call has no use and is defined as 'false'.
Return values
trueThere are more logs to process in the buffer.
falseNo more logs in the buffer.

Typedef Documentation

typedef uint32_t(* nrf_log_timestamp_func_t)(void)

Timestamp function prototype.

Returns
Timestamp value.

Function Documentation

int32_t nrf_log_backend_add ( nrf_log_backend_t const *  p_backend,
nrf_log_severity_t  severity 
)

Function for adding new backend interface to the logger.

Parameters
p_backendPointer to the backend interface.
severityInitial value of severity level for each module forwarded to the backend. This option is only applicable if NRF_LOG_FILTERS_ENABLED is set.
Returns
-1 if backend cannot be added or positive number (backend ID).
void nrf_log_backend_remove ( nrf_log_backend_t const *  p_backend)

Function for removing backend from the logger.

Parameters
p_backendPointer to the backend interface.
uint8_t nrf_log_color_id_get ( uint32_t  module_id,
nrf_log_severity_t  severity 
)

Function for getting coloring of specific logs.

Parameters
module_idModule ID.
severityLog severity.
Returns
ID of the color.
ret_code_t nrf_log_config_load ( void  )

Function loads configuration from non-volatile memory using Flash Data Storage module.

Return values
NRF_SUCCESSOn successful loading.
NRF_ERROR_NOT_FOUNDConfiguration file not found.
NRF_ERROR_INTERNALOther Flash Data Storage error on reading configuration file.
ret_code_t nrf_log_config_store ( void  )

Function stores current filtering configuration into non-volatile memory using Flash Data Storage module.

Returns
NRF_SUCCESS or Flash Data Storage error code.
bool nrf_log_frontend_dequeue ( void  )

Function for handling a single log entry.

Use this function only if the logs are buffered. It takes a single entry from the buffer and attempts to process it.

Return values
trueIf there are more entries to process.
falseIf there are no more entries to process.
ret_code_t nrf_log_init ( nrf_log_timestamp_func_t  timestamp_func,
uint32_t  timestamp_freq 
)

Function for initializing the frontend and the default backend.

NRF_LOG_INIT calls this function to initialize the frontend and the backend. If custom backend is used, then NRF_LOG_INIT should not be called. Instead, frontend and user backend should be verbosely initialized.

Parameters
timestamp_funcFunction for getting a 32-bit timestamp.
timestamp_freqFrequency of the timestamp.
Returns
Error status.
uint32_t nrf_log_module_cnt_get ( void  )

Function for getting number of independent log modules registered into the logger.

Returns
Number of registered modules.
nrf_log_severity_t nrf_log_module_filter_get ( uint32_t  backend_id,
uint32_t  module_id,
bool  is_ordered_idx,
bool  dynamic 
)

Function for getting module severity level.

Parameters
backend_idBackend ID.
module_idModule ID.
is_ordered_idxModule ID is given is index in alphabetically sorted list of modules.
dynamicIt true current filter for given backend is returned. If false then compiled-in level is returned (maximum available). If this parameter is false then backend_id parameter is not used.
Returns
Severity.
void nrf_log_module_filter_set ( uint32_t  backend_id,
uint32_t  module_id,
nrf_log_severity_t  severity 
)

Function for configuring filtering ofs logs in the module.

Filtering of logs in modules is independent for each backend.

Parameters
backend_idBackend ID which want to chenge its configuration.
module_idModule ID which logs will be reconfigured.
severityNew severity filter.
const char* nrf_log_module_name_get ( uint32_t  module_id,
bool  is_ordered_idx 
)

Function for getting module name.

Parameters
module_idModule ID.
is_ordered_idxModule ID is given is index in alphabetically sorted list of modules.
Returns
Pointer to string with module name.
void nrf_log_panic ( void  )

Function for setting logger backends into panic mode.

When this function is called all attached backends are informed about panic state of the system. It is up to the backend to react properly (hold or process logs in blocking mode, etc.)


Documentation feedback | Developer Zone | Subscribe | Updated