nRF5 SDK v15.3.0
Modules | Macros | Functions

The nrf_log module interface. More...

Modules

 Logger configuration
 
 Flash logger backend
 Flash logger backend.
 
 Logger backend interface
 The nrf_log backend interface.
 
 Log RTT backend
 Log RTT backend.
 
 Log UART backend
 Log UART backend.
 
 Functions for controlling nrf_log
 The nrf_log control interface.
 
 Functions for initializing and adding default backends
 The nrf_log default backends.
 
 Macros for logging on instance level
 Macros for logging on instance level.
 
 String formatter for the logger messages
 
 Common part of serial backends
 The nrf_log serial backend common put function.
 

Macros

#define NRF_LOG_ERROR_STRING_GET(code)   ""
 
#define NRF_LOG_LEVEL   NRF_LOG_DEFAULT_LEVEL
 Severity level for the module. More...
 
#define NRF_LOG_INITIAL_LEVEL   NRF_LOG_LEVEL
 Initial severity if filtering is enabled.
 
#define NRF_LOG_ERROR(...)   NRF_LOG_INTERNAL_ERROR(__VA_ARGS__)
 Macro for logging error messages. It takes a printf-like, formatted string with up to seven arguments. More...
 
#define NRF_LOG_WARNING(...)   NRF_LOG_INTERNAL_WARNING( __VA_ARGS__)
 Macro for logging error messages. It takes a printf-like, formatted string with up to seven arguments. More...
 
#define NRF_LOG_INFO(...)   NRF_LOG_INTERNAL_INFO( __VA_ARGS__)
 Macro for logging error messages. It takes a printf-like, formatted string with up to seven arguments. More...
 
#define NRF_LOG_DEBUG(...)   NRF_LOG_INTERNAL_DEBUG( __VA_ARGS__)
 Macro for logging error messages. It takes a printf-like, formatted string with up to seven arguments. More...
 
#define NRF_LOG_INST_ERROR(p_inst,...)   NRF_LOG_INTERNAL_INST_ERROR(p_inst,__VA_ARGS__)
 Macro for logging error messages for a given module instance. It takes a printf-like, formatted string with up to seven arguments. More...
 
#define NRF_LOG_INST_WARNING(p_inst,...)   NRF_LOG_INTERNAL_INST_WARNING(p_inst,__VA_ARGS__)
 Macro for logging error messages for a given module instance. It takes a printf-like, formatted string with up to seven arguments. More...
 
#define NRF_LOG_INST_INFO(p_inst,...)   NRF_LOG_INTERNAL_INST_INFO(p_inst, __VA_ARGS__)
 Macro for logging error messages for a given module instance. It takes a printf-like, formatted string with up to seven arguments. More...
 
#define NRF_LOG_INST_DEBUG(p_inst,...)   NRF_LOG_INTERNAL_INST_DEBUG(p_inst, __VA_ARGS__)
 Macro for logging error messages for given module instance. It takes a printf-like, formatted string with up to seven arguments. More...
 
#define NRF_LOG_RAW_INFO(...)   NRF_LOG_INTERNAL_RAW_INFO( __VA_ARGS__)
 Macro for logging a formatted string without any prefix or timestamp.
 
#define NRF_LOG_HEXDUMP_ERROR(p_data, len)   NRF_LOG_INTERNAL_HEXDUMP_ERROR(p_data, len)
 Macro for logging raw bytes. More...
 
#define NRF_LOG_HEXDUMP_WARNING(p_data, len)   NRF_LOG_INTERNAL_HEXDUMP_WARNING(p_data, len)
 Macro for logging raw bytes. More...
 
#define NRF_LOG_HEXDUMP_INFO(p_data, len)   NRF_LOG_INTERNAL_HEXDUMP_INFO(p_data, len)
 Macro for logging raw bytes. More...
 
#define NRF_LOG_HEXDUMP_DEBUG(p_data, len)   NRF_LOG_INTERNAL_HEXDUMP_DEBUG(p_data, len)
 Macro for logging raw bytes. More...
 
#define NRF_LOG_HEXDUMP_INST_ERROR(p_inst, p_data, len)   NRF_LOG_INTERNAL_HEXDUMP_INST_ERROR(p_inst, p_data, len)
 Macro for logging raw bytes for a specific module instance. More...
 
#define NRF_LOG_HEXDUMP_INST_WARNING(p_inst, p_data, len)   NRF_LOG_INTERNAL_HEXDUMP_INST_WARNING(p_inst, p_data, len)
 Macro for logging raw bytes for a specific module instance. More...
 
#define NRF_LOG_HEXDUMP_INST_INFO(p_inst, p_data, len)   NRF_LOG_INTERNAL_HEXDUMP_INST_INFO(p_inst, p_data, len)
 Macro for logging raw bytes for a specific module instance. More...
 
#define NRF_LOG_HEXDUMP_INST_DEBUG(p_inst, p_data, len)   NRF_LOG_INTERNAL_HEXDUMP_INST_DEBUG(p_inst, p_data, len)
 Macro for logging raw bytes for a specific module instance. More...
 
#define NRF_LOG_RAW_HEXDUMP_INFO(p_data, len)   NRF_LOG_INTERNAL_RAW_HEXDUMP_INFO(p_data, len)
 Macro for logging hexdump without any prefix or timestamp.
 
#define NRF_LOG_PUSH(_str)   NRF_LOG_INTERNAL_LOG_PUSH(_str)
 Macro for copying a string to internal logger buffer if logs are deferred. More...
 
#define NRF_LOG_FLOAT_MARKER   "%s%d.%02d"
 Macro to be used in a formatted string to a pass float number to the log. More...
 
#define NRF_LOG_FLOAT(val)
 Macro for dissecting a float number into two numbers (integer and residuum). More...
 
#define NRF_LOG_MODULE_REGISTER()   NRF_LOG_INTERNAL_MODULE_REGISTER()
 Macro for registering an independent module. More...
 

Functions

char const * nrf_log_push (char *const p_str)
 Function for copying a string to the internal logger buffer if logs are deferred. More...
 

Detailed Description

The nrf_log module interface.

Macro Definition Documentation

#define NRF_LOG_DEBUG (   ...)    NRF_LOG_INTERNAL_DEBUG( __VA_ARGS__)

Macro for logging error messages. It takes a printf-like, formatted string with up to seven arguments.

This macro is compiled only if NRF_LOG_LEVEL includes debug logs.

#define NRF_LOG_ERROR (   ...)    NRF_LOG_INTERNAL_ERROR(__VA_ARGS__)

Macro for logging error messages. It takes a printf-like, formatted string with up to seven arguments.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

#define NRF_LOG_FLOAT (   val)
Value:
(uint32_t)(((val) < 0 && (val) > -1.0) ? "-" : ""), \
(int32_t)(val), \
(int32_t)((((val) > 0) ? (val) - (int32_t)(val) \
: (int32_t)(val) - (val))*100)

Macro for dissecting a float number into two numbers (integer and residuum).

#define NRF_LOG_FLOAT_MARKER   "%s%d.%02d"

Macro to be used in a formatted string to a pass float number to the log.

Use this macro in a formatted string instead of the f specifier together with NRF_LOG_FLOAT macro. Example: NRF_LOG_INFO("My float number" NRF_LOG_FLOAT_MARKER "\r\n", NRF_LOG_FLOAT(f)))

#define NRF_LOG_HEXDUMP_DEBUG (   p_data,
  len 
)    NRF_LOG_INTERNAL_HEXDUMP_DEBUG(p_data, len)

Macro for logging raw bytes.

This macro is compiled only if NRF_LOG_LEVEL includes debug logs.

Parameters
p_dataPointer to data.
lenData length in bytes.
#define NRF_LOG_HEXDUMP_ERROR (   p_data,
  len 
)    NRF_LOG_INTERNAL_HEXDUMP_ERROR(p_data, len)

Macro for logging raw bytes.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

Parameters
p_dataPointer to data.
lenData length in bytes.
#define NRF_LOG_HEXDUMP_INFO (   p_data,
  len 
)    NRF_LOG_INTERNAL_HEXDUMP_INFO(p_data, len)

Macro for logging raw bytes.

This macro is compiled only if NRF_LOG_LEVEL includes info logs.

Parameters
p_dataPointer to data.
lenData length in bytes.
#define NRF_LOG_HEXDUMP_INST_DEBUG (   p_inst,
  p_data,
  len 
)    NRF_LOG_INTERNAL_HEXDUMP_INST_DEBUG(p_inst, p_data, len)

Macro for logging raw bytes for a specific module instance.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

Parameters
p_instPointer to the instance with logging support.
p_dataPointer to data.
lenData length in bytes.
#define NRF_LOG_HEXDUMP_INST_ERROR (   p_inst,
  p_data,
  len 
)    NRF_LOG_INTERNAL_HEXDUMP_INST_ERROR(p_inst, p_data, len)

Macro for logging raw bytes for a specific module instance.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

Parameters
p_instPointer to the instance with logging support.
p_dataPointer to data.
lenData length in bytes.
#define NRF_LOG_HEXDUMP_INST_INFO (   p_inst,
  p_data,
  len 
)    NRF_LOG_INTERNAL_HEXDUMP_INST_INFO(p_inst, p_data, len)

Macro for logging raw bytes for a specific module instance.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

Parameters
p_instPointer to the instance with logging support.
p_dataPointer to data.
lenData length in bytes.
#define NRF_LOG_HEXDUMP_INST_WARNING (   p_inst,
  p_data,
  len 
)    NRF_LOG_INTERNAL_HEXDUMP_INST_WARNING(p_inst, p_data, len)

Macro for logging raw bytes for a specific module instance.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

Parameters
p_instPointer to the instance with logging support.
p_dataPointer to data.
lenData length in bytes.
#define NRF_LOG_HEXDUMP_WARNING (   p_data,
  len 
)    NRF_LOG_INTERNAL_HEXDUMP_WARNING(p_data, len)

Macro for logging raw bytes.

This macro is compiled only if NRF_LOG_LEVEL includes warning logs.

Parameters
p_dataPointer to data.
lenData length in bytes.
#define NRF_LOG_INFO (   ...)    NRF_LOG_INTERNAL_INFO( __VA_ARGS__)

Macro for logging error messages. It takes a printf-like, formatted string with up to seven arguments.

This macro is compiled only if NRF_LOG_LEVEL includes info logs.

#define NRF_LOG_INST_DEBUG (   p_inst,
  ... 
)    NRF_LOG_INTERNAL_INST_DEBUG(p_inst, __VA_ARGS__)

Macro for logging error messages for given module instance. It takes a printf-like, formatted string with up to seven arguments.

Parameters
p_instPointer to the instance with logging support.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

#define NRF_LOG_INST_ERROR (   p_inst,
  ... 
)    NRF_LOG_INTERNAL_INST_ERROR(p_inst,__VA_ARGS__)

Macro for logging error messages for a given module instance. It takes a printf-like, formatted string with up to seven arguments.

Parameters
p_instPointer to the instance with logging support.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

#define NRF_LOG_INST_INFO (   p_inst,
  ... 
)    NRF_LOG_INTERNAL_INST_INFO(p_inst, __VA_ARGS__)

Macro for logging error messages for a given module instance. It takes a printf-like, formatted string with up to seven arguments.

Parameters
p_instPointer to the instance with logging support.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

#define NRF_LOG_INST_WARNING (   p_inst,
  ... 
)    NRF_LOG_INTERNAL_INST_WARNING(p_inst,__VA_ARGS__)

Macro for logging error messages for a given module instance. It takes a printf-like, formatted string with up to seven arguments.

Parameters
p_instPointer to the instance with logging support.

This macro is compiled only if NRF_LOG_LEVEL includes error logs.

#define NRF_LOG_LEVEL   NRF_LOG_DEFAULT_LEVEL

Severity level for the module.

The severity level can be defined in a module to override the default.

#define NRF_LOG_MODULE_REGISTER ( )    NRF_LOG_INTERNAL_MODULE_REGISTER()

Macro for registering an independent module.

Registration creates set of dynamic (RAM) and constant variables associated with the module.

#define NRF_LOG_PUSH (   _str)    NRF_LOG_INTERNAL_LOG_PUSH(_str)

Macro for copying a string to internal logger buffer if logs are deferred.

Parameters
_strString.
#define NRF_LOG_WARNING (   ...)    NRF_LOG_INTERNAL_WARNING( __VA_ARGS__)

Macro for logging error messages. It takes a printf-like, formatted string with up to seven arguments.

This macro is compiled only if NRF_LOG_LEVEL includes warning logs.

Function Documentation

char const* nrf_log_push ( char *const  p_str)

Function for copying a string to the internal logger buffer if logs are deferred.

Use this function to store a string that is volatile (for example allocated on stack) or that may change before the deferred logs are processed. Such string is copied into the internal logger buffer (see NRF_LOG_STR_PUSH_BUFFER_SIZE).

Note
String storing is not reliable. It means that string is copied to the buffer but there is no indication when it was used and could be freed. String may be overwritten by another nrf_log_push call before being processed. For reliable data dumping use hexdump macros (e.g. NRF_LOG_HEXDUMP_INFO).
If the logs are not deferred, then this function returns the input parameter.
Parameters
p_strPointer to the user string.
Returns
Address to the location where the string is stored in the internal logger buffer.

Documentation feedback | Developer Zone | Subscribe | Updated