Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Log link API. More...

Data Structures

struct  log_link_config
 
struct  log_link_api
 
struct  log_link_ctrl_blk
 
struct  log_link
 

Macros

#define LOG_LINK_DEF(_name, _api, _buf_wlen, _ctx)
 Create instance of a log link.
 

Typedefs

typedef void(* log_link_callback_t) (const struct log_link *link, union log_msg_generic *msg)
 
typedef void(* log_link_dropped_cb_t) (const struct log_link *link, uint32_t dropped)
 

Functions

static int log_link_initiate (const struct log_link *link, struct log_link_config *config)
 Initiate log link.
 
static int log_link_activate (const struct log_link *link)
 Activate log link.
 
static int log_link_is_active (const struct log_link *link)
 Check if link is activated.
 
static uint8_t log_link_domains_count (const struct log_link *link)
 Get number of domains in the link.
 
static uint16_t log_link_sources_count (const struct log_link *link, uint32_t domain_id)
 Get number of sources in the domain.
 
static int log_link_get_domain_name (const struct log_link *link, uint32_t domain_id, char *buf, size_t *length)
 Get domain name.
 
static int log_link_get_source_name (const struct log_link *link, uint32_t domain_id, uint16_t source_id, char *buf, size_t *length)
 Get source name.
 
static int log_link_get_levels (const struct log_link *link, uint32_t domain_id, uint16_t source_id, uint8_t *level, uint8_t *runtime_level)
 Get level settings of the given source.
 
static int log_link_set_runtime_level (const struct log_link *link, uint32_t domain_id, uint16_t source_id, uint8_t level)
 Set runtime level of the given source.
 

Detailed Description

Log link API.

Macro Definition Documentation

◆ LOG_LINK_DEF

#define LOG_LINK_DEF (   _name,
  _api,
  _buf_wlen,
  _ctx 
)

#include <zephyr/logging/log_link.h>

Value:
static uint32_t __aligned(Z_LOG_MSG_ALIGNMENT) _name##_buf32[_buf_wlen]; \
static const struct mpsc_pbuf_buffer_config _name##_mpsc_pbuf_config = { \
.buf = (uint32_t *)_name##_buf32, \
.size = _buf_wlen, \
.notify_drop = z_log_notify_drop, \
.flags = IS_ENABLED(CONFIG_LOG_MODE_OVERFLOW) ? \
}; \
COND_CODE_0(_buf_wlen, (), (static STRUCT_SECTION_ITERABLE(log_msg_ptr, \
_name##_log_msg_ptr);)) \
_name##_log_mpsc_pbuf); \
static struct log_link_ctrl_blk _name##_ctrl_blk; \
static const STRUCT_SECTION_ITERABLE(log_link, _name) = \
{ \
.api = &_api, \
.name = STRINGIFY(_name), \
.ctrl_blk = &_name##_ctrl_blk, \
.ctx = _ctx, \
.mpsc_pbuf = _buf_wlen ? &_name##_log_mpsc_pbuf : NULL, \
.mpsc_pbuf_config = _buf_wlen ? &_name##_mpsc_pbuf_config : NULL \
}
#define STRINGIFY(s)
Definition: common.h:134
#define MPSC_PBUF_MODE_OVERWRITE
Flag indicating buffer full policy.
Definition: mpsc_pbuf.h:59
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition: iterable_sections.h:216
#define STRUCT_SECTION_ITERABLE_ALTERNATE(secname, struct_type, varname)
Defines a new element of alternate data type for an iterable section.
Definition: iterable_sections.h:188
static uint32_t log_msg_generic_get_wlen(const union mpsc_pbuf_generic *item)
Get length of the log item.
Definition: log_msg.h:745
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:124
flags
Definition: parser.h:96
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
Structure wrapper to be used for memory section.
Definition: log_internal.h:24
Structure wrapper to be used for memory section.
Definition: log_internal.h:29
MPSC packet buffer configuration.
Definition: mpsc_pbuf.h:131
uint32_t * buf
Definition: mpsc_pbuf.h:133
mpsc_pbuf_notify_drop notify_drop
Definition: mpsc_pbuf.h:139
mpsc_pbuf_get_wlen get_wlen
Definition: mpsc_pbuf.h:140
uint32_t size
Definition: mpsc_pbuf.h:136
MPSC packet buffer structure.
Definition: mpsc_pbuf.h:90

Create instance of a log link.

Link can have dedicated buffer for messages if _buf_len is positive. In that case messages will be processed in an order since logging core will attempt to fetch message from all available buffers (default and links) and process the one with the earliest timestamp. If strict ordering is not needed then dedicated buffer may be omitted (_buf_len set to 0). That results in better memory utilization but unordered messages passed to backends.

Parameters
_nameInstance name.
_apiAPI list. See log_link_api.
_buf_wlenSize (in words) of dedicated buffer for messages from this buffer. If 0 default buffer is used.
_ctxContext (void *) associated with the link.

Typedef Documentation

◆ log_link_callback_t

typedef void(* log_link_callback_t) (const struct log_link *link, union log_msg_generic *msg)

◆ log_link_dropped_cb_t

typedef void(* log_link_dropped_cb_t) (const struct log_link *link, uint32_t dropped)

Function Documentation

◆ log_link_activate()

static int log_link_activate ( const struct log_link link)
inlinestatic

#include <zephyr/logging/log_link.h>

Activate log link.

Function checks if link is initilized and completes initialization process. When successfully returns, link is ready with domain and sources count fetched and timestamp details updated.

Parameters
linkLog link instance.
Return values
0When successfully activated.
-EINPROGRESSActivation in progress.

◆ log_link_domains_count()

static uint8_t log_link_domains_count ( const struct log_link link)
inlinestatic

#include <zephyr/logging/log_link.h>

Get number of domains in the link.

Parameters
[in]linkLog link instance.
Returns
Number of domains.

◆ log_link_get_domain_name()

static int log_link_get_domain_name ( const struct log_link link,
uint32_t  domain_id,
char *  buf,
size_t length 
)
inlinestatic

#include <zephyr/logging/log_link.h>

Get domain name.

Parameters
[in]linkLog link instance.
[in]domain_idRelative domain ID.
[out]bufOutput buffer filled with domain name. If NULL then name length is returned.
[in,out]lengthBuffer size. Name is trimmed if it does not fit in the buffer and field is set to actual name length.
Returns
0 on success or error code.

◆ log_link_get_levels()

static int log_link_get_levels ( const struct log_link link,
uint32_t  domain_id,
uint16_t  source_id,
uint8_t level,
uint8_t runtime_level 
)
inlinestatic

#include <zephyr/logging/log_link.h>

Get level settings of the given source.

Parameters
[in]linkLog link instance.
[in]domain_idRelative domain ID.
[in]source_idSource ID.
[out]levelLocation to store requested compile time level.
[out]runtime_levelLocation to store requested runtime time level.
Returns
0 on success or error code.

◆ log_link_get_source_name()

static int log_link_get_source_name ( const struct log_link link,
uint32_t  domain_id,
uint16_t  source_id,
char *  buf,
size_t length 
)
inlinestatic

#include <zephyr/logging/log_link.h>

Get source name.

Parameters
[in]linkLog link instance.
[in]domain_idRelative domain ID.
[in]source_idSource ID.
[out]bufOutput buffer filled with source name.
[in,out]lengthBuffer size. Name is trimmed if it does not fit in the buffer and field is set to actual name length.
Returns
0 on success or error code.

◆ log_link_initiate()

static int log_link_initiate ( const struct log_link link,
struct log_link_config config 
)
inlinestatic

#include <zephyr/logging/log_link.h>

Initiate log link.

Function initiates the link. Since initialization procedure may be time consuming, function returns before link is ready to not block logging initialization. log_link_activate is called to complete link initialization.

Parameters
linkLog link instance.
configConfiguration.
Returns
0 on success or error code.

◆ log_link_is_active()

static int log_link_is_active ( const struct log_link link)
inlinestatic

#include <zephyr/logging/log_link.h>

Check if link is activated.

Parameters
linkLog link instance.
Return values
0When successfully activated.
-EINPROGRESSActivation in progress.

◆ log_link_set_runtime_level()

static int log_link_set_runtime_level ( const struct log_link link,
uint32_t  domain_id,
uint16_t  source_id,
uint8_t  level 
)
inlinestatic

#include <zephyr/logging/log_link.h>

Set runtime level of the given source.

Parameters
[in]linkLog link instance.
[in]domain_idRelative domain ID.
[in]source_idSource ID.
[out]levelRequested level.
Returns
0 on success or error code.

◆ log_link_sources_count()

static uint16_t log_link_sources_count ( const struct log_link link,
uint32_t  domain_id 
)
inlinestatic

#include <zephyr/logging/log_link.h>

Get number of sources in the domain.

Parameters
[in]linkLog link instance.
[in]domain_idRelative domain ID.
Returns
Source count.