Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
log_core.h File Reference
#include <zephyr/logging/log_msg.h>
#include <zephyr/logging/log_instance.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
#include <zephyr/sys/util.h>

Go to the source code of this file.

Macros

#define LOG_LEVEL_NONE   0
 
#define LOG_LEVEL_ERR   1
 
#define LOG_LEVEL_WRN   2
 
#define LOG_LEVEL_INF   3
 
#define LOG_LEVEL_DBG   4
 
#define CONFIG_LOG_DEFAULT_LEVEL   0
 
#define CONFIG_LOG_MAX_LEVEL   0
 
#define LOG_FUNCTION_PREFIX_MASK
 
#define LOG_CURRENT_MODULE_ID()
 Macro for getting ID of current module.
 
#define LOG_POINTERS_VALIDATE(string_ok, ...)
 
#define LOG_STRING_WARNING(_mode, _src, ...)
 
#define LOG_LEVEL_BITS   3U
 Number of bits used to encode log level.
 
#define LOG_FILTER_SLOT_SIZE   LOG_LEVEL_BITS
 Filter slot size.
 
#define LOG_FILTERS_NUM_OF_SLOTS   (32 / LOG_FILTER_SLOT_SIZE)
 Number of slots in one word.
 
#define LOG_FILTERS_MAX_BACKENDS    (LOG_FILTERS_NUM_OF_SLOTS - (1 + IS_ENABLED(CONFIG_LOG_FRONTEND)))
 Maximum number of backends supported when runtime filtering is enabled.
 
#define LOG_FRONTEND_SLOT_ID   (LOG_FILTERS_NUM_OF_SLOTS - 1)
 Slot reserved for the frontend.
 
#define LOG_FILTER_SLOT_MASK   (BIT(LOG_FILTER_SLOT_SIZE) - 1U)
 Slot mask.
 
#define LOG_FILTER_SLOT_SHIFT(_id)
 Bit offset of a slot.
 
#define LOG_FILTER_SLOT_GET(_filters, _id)
 
#define LOG_FILTER_SLOT_SET(_filters, _id, _filter)
 
#define LOG_FILTER_AGGR_SLOT_IDX   0
 
#define LOG_FILTER_AGGR_SLOT_GET(_filters)
 
#define LOG_FILTER_FIRST_BACKEND_SLOT_IDX   1
 
#define LOG_LEVEL_INTERNAL_RAW_STRING   LOG_LEVEL_NONE
 Log level value used to indicate log entry that should not be formatted (raw string).
 
#define LOG_ITEM_DYNAMIC_DATA(_name)
 Creates name of variable and section for runtime log data.
 
#define LOG_INSTANCE_DYNAMIC_DATA(_module_name, _inst)
 

Functions

 TYPE_SECTION_START_EXTERN (struct log_source_const_data, log_const)
 
 TYPE_SECTION_END_EXTERN (struct log_source_const_data, log_const)
 
static uint32_t log_const_source_id (const struct log_source_const_data *data)
 Get index of the log source based on the address of the constant data associated with the source.
 
 TYPE_SECTION_START_EXTERN (struct log_source_dynamic_data, log_dynamic)
 
 TYPE_SECTION_END_EXTERN (struct log_source_dynamic_data, log_dynamic)
 
static uint32_t log_dynamic_source_id (struct log_source_dynamic_data *data)
 Get index of the log source based on the address of the dynamic data associated with the source.
 
static uint32_t log_source_id (const void *source)
 Get index of the log source based on the address of the associated data.
 
static void log_generic (uint8_t level, const char *fmt, va_list ap)
 Write a generic log message.
 

Macro Definition Documentation

◆ CONFIG_LOG_DEFAULT_LEVEL

#define CONFIG_LOG_DEFAULT_LEVEL   0

◆ CONFIG_LOG_MAX_LEVEL

#define CONFIG_LOG_MAX_LEVEL   0

◆ LOG_CURRENT_MODULE_ID

#define LOG_CURRENT_MODULE_ID ( )
Value:
(__log_level != 0 ? \
log_const_source_id(__log_current_const_data) : 0U)

Macro for getting ID of current module.

◆ LOG_FILTER_AGGR_SLOT_GET

#define LOG_FILTER_AGGR_SLOT_GET ( _filters)
Value:
#define LOG_FILTER_AGGR_SLOT_IDX
Definition log_core.h:411
#define LOG_FILTER_SLOT_GET(_filters, _id)
Definition log_core.h:400

◆ LOG_FILTER_AGGR_SLOT_IDX

#define LOG_FILTER_AGGR_SLOT_IDX   0

◆ LOG_FILTER_FIRST_BACKEND_SLOT_IDX

#define LOG_FILTER_FIRST_BACKEND_SLOT_IDX   1

◆ LOG_FILTER_SLOT_GET

#define LOG_FILTER_SLOT_GET ( _filters,
_id )
Value:
((*(_filters) >> LOG_FILTER_SLOT_SHIFT(_id)) & LOG_FILTER_SLOT_MASK)
#define LOG_FILTER_SLOT_SHIFT(_id)
Bit offset of a slot.
Definition log_core.h:398
#define LOG_FILTER_SLOT_MASK
Slot mask.
Definition log_core.h:392

◆ LOG_FILTER_SLOT_MASK

#define LOG_FILTER_SLOT_MASK   (BIT(LOG_FILTER_SLOT_SIZE) - 1U)

Slot mask.

◆ LOG_FILTER_SLOT_SET

#define LOG_FILTER_SLOT_SET ( _filters,
_id,
_filter )
Value:
do { \
*(_filters) &= ~(LOG_FILTER_SLOT_MASK << \
*(_filters) |= ((_filter) & LOG_FILTER_SLOT_MASK) << \
LOG_FILTER_SLOT_SHIFT(_id); \
} while (false)

◆ LOG_FILTER_SLOT_SHIFT

#define LOG_FILTER_SLOT_SHIFT ( _id)
Value:
#define LOG_FILTER_SLOT_SIZE
Filter slot size.
Definition log_core.h:379

Bit offset of a slot.

Parameters
_idSlot ID.

◆ LOG_FILTER_SLOT_SIZE

#define LOG_FILTER_SLOT_SIZE   LOG_LEVEL_BITS

Filter slot size.

◆ LOG_FILTERS_MAX_BACKENDS

#define LOG_FILTERS_MAX_BACKENDS    (LOG_FILTERS_NUM_OF_SLOTS - (1 + IS_ENABLED(CONFIG_LOG_FRONTEND)))

Maximum number of backends supported when runtime filtering is enabled.

◆ LOG_FILTERS_NUM_OF_SLOTS

#define LOG_FILTERS_NUM_OF_SLOTS   (32 / LOG_FILTER_SLOT_SIZE)

Number of slots in one word.

◆ LOG_FRONTEND_SLOT_ID

#define LOG_FRONTEND_SLOT_ID   (LOG_FILTERS_NUM_OF_SLOTS - 1)

Slot reserved for the frontend.

Last slot is used.

◆ LOG_FUNCTION_PREFIX_MASK

#define LOG_FUNCTION_PREFIX_MASK
Value:
(((uint32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_ERR) << \
((uint32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_WRN) << \
((uint32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_INF) << \
((uint32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_DBG) << LOG_LEVEL_DBG))
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:140
#define LOG_LEVEL_INF
Definition log_core.h:22
#define LOG_LEVEL_WRN
Definition log_core.h:21
#define LOG_LEVEL_ERR
Definition log_core.h:20
#define LOG_LEVEL_DBG
Definition log_core.h:23
__UINT32_TYPE__ uint32_t
Definition stdint.h:90

◆ LOG_INSTANCE_DYNAMIC_DATA

#define LOG_INSTANCE_DYNAMIC_DATA ( _module_name,
_inst )
Value:
LOG_ITEM_DYNAMIC_DATA(Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst))
#define LOG_ITEM_DYNAMIC_DATA(_name)
Creates name of variable and section for runtime log data.
Definition log_core.h:481

◆ LOG_ITEM_DYNAMIC_DATA

#define LOG_ITEM_DYNAMIC_DATA ( _name)
Value:
UTIL_CAT(log_dynamic_, _name)
#define UTIL_CAT(a,...)
Definition util_internal.h:104

Creates name of variable and section for runtime log data.

Parameters
_nameName.

◆ LOG_LEVEL_BITS

#define LOG_LEVEL_BITS   3U

Number of bits used to encode log level.

◆ LOG_LEVEL_DBG

#define LOG_LEVEL_DBG   4

◆ LOG_LEVEL_ERR

#define LOG_LEVEL_ERR   1

◆ LOG_LEVEL_INF

#define LOG_LEVEL_INF   3

◆ LOG_LEVEL_INTERNAL_RAW_STRING

#define LOG_LEVEL_INTERNAL_RAW_STRING   LOG_LEVEL_NONE

Log level value used to indicate log entry that should not be formatted (raw string).

◆ LOG_LEVEL_NONE

#define LOG_LEVEL_NONE   0

◆ LOG_LEVEL_WRN

#define LOG_LEVEL_WRN   2

◆ LOG_POINTERS_VALIDATE

#define LOG_POINTERS_VALIDATE ( string_ok,
... )
Value:
string_ok = true

◆ LOG_STRING_WARNING

#define LOG_STRING_WARNING ( _mode,
_src,
... )

Function Documentation

◆ log_const_source_id()

static uint32_t log_const_source_id ( const struct log_source_const_data * data)
inlinestatic

Get index of the log source based on the address of the constant data associated with the source.

Parameters
dataAddress of the constant data.
Returns
Source ID.

◆ log_dynamic_source_id()

static uint32_t log_dynamic_source_id ( struct log_source_dynamic_data * data)
inlinestatic

Get index of the log source based on the address of the dynamic data associated with the source.

Parameters
dataAddress of the dynamic data.
Returns
Source ID.

◆ log_generic()

static void log_generic ( uint8_t level,
const char * fmt,
va_list ap )
inlinestatic

Write a generic log message.

Note
This function is intended to be used when porting other log systems.
Parameters
levelLog level..
fmtString to format.
apPointer to arguments list.

◆ log_source_id()

static uint32_t log_source_id ( const void * source)
inlinestatic

Get index of the log source based on the address of the associated data.

Parameters
sourceAddress of the data structure (dynamic if runtime filtering is enabled and static otherwise).
Returns
Source ID.

◆ TYPE_SECTION_END_EXTERN() [1/2]

TYPE_SECTION_END_EXTERN ( struct log_source_const_data ,
log_const  )

◆ TYPE_SECTION_END_EXTERN() [2/2]

TYPE_SECTION_END_EXTERN ( struct log_source_dynamic_data ,
log_dynamic  )

◆ TYPE_SECTION_START_EXTERN() [1/2]

TYPE_SECTION_START_EXTERN ( struct log_source_const_data ,
log_const  )

◆ TYPE_SECTION_START_EXTERN() [2/2]

TYPE_SECTION_START_EXTERN ( struct log_source_dynamic_data ,
log_dynamic  )