Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
log_instance.h File Reference

Go to the source code of this file.

Data Structures

struct  log_source_const_data
 Constant data associated with the source of log messages. More...
 
struct  log_source_dynamic_data
 Dynamic data associated with the source of log messages. More...
 

Macros

#define LOG_OBJECT_PTR_INIT(_name, _object)
 Initialize pointer to logger instance with explicitly provided object.
 
#define LOG_INSTANCE_PTR(_module_name, _inst_name)
 Get pointer to a logging instance.
 
#define LOG_INSTANCE_PTR_INIT(_name, _module_name, _inst_name)
 Macro for initializing a pointer to the logger instance.
 
#define LOG_INSTANCE_PTR_DECLARE(_name)
 Declare a logger instance pointer in the module structure.
 
#define LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level)
 Macro for registering instance for logging with independent filtering.
 

Macro Definition Documentation

◆ LOG_INSTANCE_PTR

#define LOG_INSTANCE_PTR ( _module_name,
_inst_name )
Value:
Z_LOG_OBJECT_PTR(Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst_name))

Get pointer to a logging instance.

Instance is identified by _module_name and _inst_name.

Parameters
_module_nameModule name.
_inst_nameInstance name.
Returns
Pointer to a logging instance.

◆ LOG_INSTANCE_PTR_DECLARE

#define LOG_INSTANCE_PTR_DECLARE ( _name)
Value:
COND_CODE_1(CONFIG_LOG, (Z_LOG_INSTANCE_STRUCT * _name), \
(int _name[TOOLCHAIN_HAS_ZLA ? 0 : 1]))
#define COND_CODE_1(_flag, _if_1_code, _else_code)
Insert code depending on whether _flag expands to 1 or not.
Definition util_macro.h:195
#define TOOLCHAIN_HAS_ZLA
Indicate if toolchain supports Zero Length Arrays.
Definition toolchain.h:123

Declare a logger instance pointer in the module structure.

If logging is disabled then element in the structure is still declared to avoid compilation issues. If compiler supports zero length arrays then it is utilized to not use any space, else a byte array is created.

Parameters
_nameName of a structure element that will have a pointer to logging instance object.

◆ LOG_INSTANCE_PTR_INIT

#define LOG_INSTANCE_PTR_INIT ( _name,
_module_name,
_inst_name )
Value:
LOG_OBJECT_PTR_INIT(_name, LOG_INSTANCE_PTR(_module_name, _inst_name))
#define LOG_OBJECT_PTR_INIT(_name, _object)
Initialize pointer to logger instance with explicitly provided object.
Definition log_instance.h:81
#define LOG_INSTANCE_PTR(_module_name, _inst_name)
Get pointer to a logging instance.
Definition log_instance.h:114

Macro for initializing a pointer to the logger instance.

_module_name and _inst_name are concatenated to form a name of the object.

Macro is intended to be used in user structure initializer to initialize a field in the structure that holds pointer to the logging instance. Structure field should be declared using LOG_INSTANCE_PTR_DECLARE.

Parameters
_nameName of a structure element that have a pointer to logging instance object.
_module_nameModule name.
_inst_nameInstance name.

◆ LOG_INSTANCE_REGISTER

#define LOG_INSTANCE_REGISTER ( _module_name,
_inst_name,
_level )
Value:
IF_ENABLED(CONFIG_LOG, (Z_LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level)))
#define IF_ENABLED(_flag, _code)
Insert code if _flag is defined and equals 1.
Definition util_macro.h:239

Macro for registering instance for logging with independent filtering.

Module instance provides filtering of logs on instance level instead of module level. Instance create using this macro can later on be used with LOG_INSTANCE_PTR_INIT or referenced by LOG_INSTANCE_PTR.

Parameters
_module_nameModule name.
_inst_nameInstance name.
_levelInitial static filtering.

◆ LOG_OBJECT_PTR_INIT

#define LOG_OBJECT_PTR_INIT ( _name,
_object )
Value:
IF_ENABLED(CONFIG_LOG, (._name = _object,))

Initialize pointer to logger instance with explicitly provided object.

Macro can be used to initialized a pointer with object that is not unique to the given instance, thus not created with LOG_INSTANCE_REGISTER.

Parameters
_nameName of the structure element for holding logging object.
_objectPointer to a logging instance object.