Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
Logger backend interface

Logger backend interface. More...

Data Structures

struct  log_backend_api
 Logger backend API. More...
 
struct  log_backend_control_block
 Logger backend control block. More...
 
struct  log_backend
 Logger backend structure. More...
 

Macros

#define LOG_BACKEND_DEFINE(_name, _api, _autostart, ...)
 Macro for creating a logger backend instance. More...
 

Functions

static void log_backend_put (const struct log_backend *const backend, struct log_msg *msg)
 Put message with log entry to the backend. More...
 
static void log_backend_msg2_process (const struct log_backend *const backend, union log_msg2_generic *msg)
 
static void log_backend_put_sync_string (const struct log_backend *const backend, struct log_msg_ids src_level, uint32_t timestamp, const char *fmt, va_list ap)
 Synchronously process log message. More...
 
static void log_backend_put_sync_hexdump (const struct log_backend *const backend, struct log_msg_ids src_level, uint32_t timestamp, const char *metadata, const uint8_t *data, uint32_t len)
 Synchronously process log hexdump_message. More...
 
static void log_backend_dropped (const struct log_backend *const backend, uint32_t cnt)
 Notify backend about dropped log messages. More...
 
static void log_backend_panic (const struct log_backend *const backend)
 Reconfigure backend to panic mode. More...
 
static void log_backend_id_set (const struct log_backend *const backend, uint8_t id)
 Set backend id. More...
 
static uint8_t log_backend_id_get (const struct log_backend *const backend)
 Get backend id. More...
 
static const struct log_backendlog_backend_get (uint32_t idx)
 Get backend. More...
 
static int log_backend_count_get (void)
 Get number of backends. More...
 
static void log_backend_activate (const struct log_backend *const backend, void *ctx)
 Activate backend. More...
 
static void log_backend_deactivate (const struct log_backend *const backend)
 Deactivate backend. More...
 
static bool log_backend_is_active (const struct log_backend *const backend)
 Check state of the backend. More...
 

Detailed Description

Logger backend interface.

Macro Definition Documentation

◆ LOG_BACKEND_DEFINE

#define LOG_BACKEND_DEFINE (   _name,
  _api,
  _autostart,
  ... 
)

#include <include/logging/log_backend.h>

Value:
static struct log_backend_control_block UTIL_CAT(backend_cb_, _name) = \
{ \
COND_CODE_0(NUM_VA_ARGS_LESS_1(_, ##__VA_ARGS__), \
(), (.ctx = __VA_ARGS__,)) \
.id = 0, \
.active = false, \
}; \
static const STRUCT_SECTION_ITERABLE(log_backend, _name) = \
{ \
.api = &_api, \
.cb = &UTIL_CAT(backend_cb_, _name), \
.name = STRINGIFY(_name), \
.autostart = _autostart \
}
#define STRINGIFY(s)
Definition: common.h:121
#define STRUCT_SECTION_ITERABLE(struct_type, name)
Defines a new iterable section.
Definition: common.h:199
#define NUM_VA_ARGS_LESS_1(...)
Number of arguments in the variable arguments list minus one.
Definition: util_macro.h:556
Logger backend control block.
Definition: log_backend.h:53
void * ctx
Definition: log_backend.h:54
Logger backend structure.
Definition: log_backend.h:62
#define UTIL_CAT(a,...)
Definition: util_internal.h:84

Macro for creating a logger backend instance.

Parameters
_nameName of the backend instance.
_apiLogger backend API.
_autostartIf true backend is initialized and activated together with the logger subsystem.
...Optional context.

Function Documentation

◆ log_backend_activate()

static void log_backend_activate ( const struct log_backend *const  backend,
void ctx 
)
inlinestatic

#include <include/logging/log_backend.h>

Activate backend.

Parameters
[in]backendPointer to the backend instance.
[in]ctxUser context.

◆ log_backend_count_get()

static int log_backend_count_get ( void  )
inlinestatic

#include <include/logging/log_backend.h>

Get number of backends.

Returns
Number of backends.

◆ log_backend_deactivate()

static void log_backend_deactivate ( const struct log_backend *const  backend)
inlinestatic

#include <include/logging/log_backend.h>

Deactivate backend.

Parameters
[in]backendPointer to the backend instance.

◆ log_backend_dropped()

static void log_backend_dropped ( const struct log_backend *const  backend,
uint32_t  cnt 
)
inlinestatic

#include <include/logging/log_backend.h>

Notify backend about dropped log messages.

Function is optional.

Parameters
[in]backendPointer to the backend instance.
[in]cntNumber of dropped logs since last notification.

◆ log_backend_get()

static const struct log_backend * log_backend_get ( uint32_t  idx)
inlinestatic

#include <include/logging/log_backend.h>

Get backend.

Parameters
[in]idxPointer to the backend instance.
Returns
Pointer to the backend instance.

◆ log_backend_id_get()

static uint8_t log_backend_id_get ( const struct log_backend *const  backend)
inlinestatic

#include <include/logging/log_backend.h>

Get backend id.

Note
It is used internally by the logger.
Parameters
[in]backendPointer to the backend instance.
Returns
Id.

◆ log_backend_id_set()

static void log_backend_id_set ( const struct log_backend *const  backend,
uint8_t  id 
)
inlinestatic

#include <include/logging/log_backend.h>

Set backend id.

Note
It is used internally by the logger.
Parameters
backendPointer to the backend instance.
idID.

◆ log_backend_is_active()

static bool log_backend_is_active ( const struct log_backend *const  backend)
inlinestatic

#include <include/logging/log_backend.h>

Check state of the backend.

Parameters
[in]backendPointer to the backend instance.
Returns
True if backend is active, false otherwise.

◆ log_backend_msg2_process()

static void log_backend_msg2_process ( const struct log_backend *const  backend,
union log_msg2_generic msg 
)
inlinestatic

◆ log_backend_panic()

static void log_backend_panic ( const struct log_backend *const  backend)
inlinestatic

#include <include/logging/log_backend.h>

Reconfigure backend to panic mode.

Parameters
[in]backendPointer to the backend instance.

◆ log_backend_put()

static void log_backend_put ( const struct log_backend *const  backend,
struct log_msg msg 
)
inlinestatic

#include <include/logging/log_backend.h>

Put message with log entry to the backend.

Parameters
[in]backendPointer to the backend instance.
[in]msgPointer to message with log entry.

◆ log_backend_put_sync_hexdump()

static void log_backend_put_sync_hexdump ( const struct log_backend *const  backend,
struct log_msg_ids  src_level,
uint32_t  timestamp,
const char *  metadata,
const uint8_t data,
uint32_t  len 
)
inlinestatic

#include <include/logging/log_backend.h>

Synchronously process log hexdump_message.

Parameters
[in]backendPointer to the backend instance.
[in]src_levelMessage details.
[in]timestampTimestamp.
[in]metadataRaw string associated with the data.
[in]dataData.
[in]lenData length.

◆ log_backend_put_sync_string()

static void log_backend_put_sync_string ( const struct log_backend *const  backend,
struct log_msg_ids  src_level,
uint32_t  timestamp,
const char *  fmt,
va_list  ap 
)
inlinestatic

#include <include/logging/log_backend.h>

Synchronously process log message.

Parameters
[in]backendPointer to the backend instance.
[in]src_levelMessage details.
[in]timestampTimestamp.
[in]fmtLog string.
[in]apLog string arguments.