Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Logger backend interface

Logger backend interface . More...

Topics

 Logger multidomain backend helpers
 Logger multidomain backend helpers.
 

Data Structures

union  log_backend_evt_arg
 Argument(s) for backend events. More...
 
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.
 

Enumerations

enum  log_backend_evt { LOG_BACKEND_EVT_PROCESS_THREAD_DONE , LOG_BACKEND_EVT_MAX }
 Backend events. More...
 

Functions

static void log_backend_init (const struct log_backend *const backend)
 Initialize or initiate the logging backend.
 
static int log_backend_is_ready (const struct log_backend *const backend)
 Poll for backend readiness.
 
static void log_backend_msg_process (const struct log_backend *const backend, union log_msg_generic *msg)
 Process message.
 
static void log_backend_dropped (const struct log_backend *const backend, uint32_t cnt)
 Notify backend about dropped log messages.
 
static void log_backend_panic (const struct log_backend *const backend)
 Reconfigure backend to panic mode.
 
static void log_backend_id_set (const struct log_backend *const backend, uint8_t id)
 Set backend id.
 
static uint8_t log_backend_id_get (const struct log_backend *const backend)
 Get backend id.
 
static const struct log_backendlog_backend_get (uint32_t idx)
 Get backend.
 
static int log_backend_count_get (void)
 Get number of backends.
 
static void log_backend_activate (const struct log_backend *const backend, void *ctx)
 Activate backend.
 
static void log_backend_deactivate (const struct log_backend *const backend)
 Deactivate backend.
 
static bool log_backend_is_active (const struct log_backend *const backend)
 Check state of the backend.
 
static int log_backend_format_set (const struct log_backend *backend, uint32_t log_type)
 Set logging format.
 
static void log_backend_notify (const struct log_backend *const backend, enum log_backend_evt event, union log_backend_evt_arg *arg)
 Notify a backend of an event.
 

Detailed Description

Logger backend interface .

Macro Definition Documentation

◆ LOG_BACKEND_DEFINE

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

#include <zephyr/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 STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition iterable_sections.h:216
#define NUM_VA_ARGS_LESS_1(...)
Number of arguments in the variable arguments list minus one.
Definition util_macro.h:647
#define STRINGIFY(s)
Definition common.h:134
Logger backend control block.
Definition log_backend.h:82
void * ctx
Definition log_backend.h:83
Logger backend structure.
Definition log_backend.h:94
#define UTIL_CAT(a,...)
Definition util_internal.h:104

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.

Enumeration Type Documentation

◆ log_backend_evt

#include <zephyr/logging/log_backend.h>

Backend events.

Enumerator
LOG_BACKEND_EVT_PROCESS_THREAD_DONE 

Event when process thread finishes processing.

This event is emitted when the process thread finishes processing pending log messages.

Note
This is not emitted when there are no pending log messages being processed.
Deferred mode only.
LOG_BACKEND_EVT_MAX 

Maximum number of backend events.

Function Documentation

◆ log_backend_activate()

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

#include <zephyr/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 <zephyr/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 <zephyr/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 <zephyr/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_format_set()

static int log_backend_format_set ( const struct log_backend * backend,
uint32_t log_type )
inlinestatic

#include <zephyr/logging/log_backend.h>

Set logging format.

Parameters
backendPointer to the backend instance.
log_typeLog format.
Return values
-ENOTSUPIf the backend does not support changing format types.
-EINVALIf the input is invalid.
0for success.

◆ log_backend_get()

static const struct log_backend * log_backend_get ( uint32_t idx)
inlinestatic

#include <zephyr/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 <zephyr/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 <zephyr/logging/log_backend.h>

Set backend id.

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

◆ log_backend_init()

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

#include <zephyr/logging/log_backend.h>

Initialize or initiate the logging backend.

If backend initialization takes longer time it could block logging thread if backend is autostarted. That is because all backends are initialized in the context of the logging thread. In that case, backend shall provide function for polling for readiness (log_backend_is_ready).

Parameters
[in]backendPointer to the backend instance.

◆ log_backend_is_active()

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

#include <zephyr/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_is_ready()

static int log_backend_is_ready ( const struct log_backend *const backend)
inlinestatic

#include <zephyr/logging/log_backend.h>

Poll for backend readiness.

If backend is ready immediately after initialization then backend may not provide this function.

Parameters
[in]backendPointer to the backend instance.
Return values
0if backend is ready.
-EBUSYif backend is not yet ready.

◆ log_backend_msg_process()

static void log_backend_msg_process ( const struct log_backend *const backend,
union log_msg_generic * msg )
inlinestatic

#include <zephyr/logging/log_backend.h>

Process message.

Function is used in deferred and immediate mode. On return, message content is processed by the backend and memory can be freed.

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

◆ log_backend_notify()

static void log_backend_notify ( const struct log_backend *const backend,
enum log_backend_evt event,
union log_backend_evt_arg * arg )
inlinestatic

#include <zephyr/logging/log_backend.h>

Notify a backend of an event.

Parameters
backendPointer to the backend instance.
eventEvent to be notified.
argPointer to the argument(s).

◆ log_backend_panic()

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

#include <zephyr/logging/log_backend.h>

Reconfigure backend to panic mode.

Parameters
[in]backendPointer to the backend instance.