6#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_BACKEND_H_
7#define ZEPHYR_INCLUDE_LOGGING_LOG_BACKEND_H_
43 const char *fmt, va_list ap);
75extern const struct log_backend __log_backends_start[];
76extern const struct log_backend __log_backends_end[];
87#define LOG_BACKEND_DEFINE(_name, _api, _autostart, ...) \
88 static struct log_backend_control_block UTIL_CAT(backend_cb_, _name) = \
90 COND_CODE_0(NUM_VA_ARGS_LESS_1(_, ##__VA_ARGS__), \
91 (), (.ctx = __VA_ARGS__,)) \
95 static const STRUCT_SECTION_ITERABLE(log_backend, _name) = \
98 .cb = &UTIL_CAT(backend_cb_, _name), \
99 .name = STRINGIFY(_name), \
100 .autostart = _autostart \
115 __ASSERT_NO_MSG(backend != NULL);
116 __ASSERT_NO_MSG(
msg != NULL);
133 __ASSERT_NO_MSG(backend != NULL);
134 __ASSERT_NO_MSG(
msg != NULL);
153 uint32_t timestamp,
const char *fmt,
156 __ASSERT_NO_MSG(backend != NULL);
179 uint32_t timestamp,
const char *metadata,
182 __ASSERT_NO_MSG(backend != NULL);
186 metadata,
data, len);
201 __ASSERT_NO_MSG(backend != NULL);
215 __ASSERT_NO_MSG(backend != NULL);
230 __ASSERT_NO_MSG(backend != NULL);
231 backend->
cb->
id = id;
244 __ASSERT_NO_MSG(backend != NULL);
245 return backend->
cb->
id;
257 return &__log_backends_start[idx];
267 return __log_backends_end - __log_backends_start;
279 __ASSERT_NO_MSG(backend != NULL);
280 backend->
cb->
ctx = ctx;
292 __ASSERT_NO_MSG(backend != NULL);
306 __ASSERT_NO_MSG(backend != NULL);
322 extern size_t log_format_table_size(
void);
324 if ((
size_t)log_type >= log_format_table_size()) {
332 if (backend == NULL) {
static void log_backend_deactivate(const struct log_backend *const backend)
Deactivate backend.
Definition: log_backend.h:289
static void log_backend_activate(const struct log_backend *const backend, void *ctx)
Activate backend.
Definition: log_backend.h:276
static bool log_backend_is_active(const struct log_backend *const backend)
Check state of the backend.
Definition: log_backend.h:303
static void log_backend_put(const struct log_backend *const backend, struct log_msg *msg)
Put message with log entry to the backend.
Definition: log_backend.h:112
static void log_backend_msg2_process(const struct log_backend *const backend, union log_msg2_generic *msg)
Process message.
Definition: log_backend.h:129
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.
Definition: log_backend.h:150
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.
Definition: log_backend.h:176
static void log_backend_id_set(const struct log_backend *const backend, uint8_t id)
Set backend id.
Definition: log_backend.h:227
static void log_backend_dropped(const struct log_backend *const backend, uint32_t cnt)
Notify backend about dropped log messages.
Definition: log_backend.h:198
static int log_backend_format_set(const struct log_backend *backend, uint32_t log_type)
Set logging format.
Definition: log_backend.h:320
static int log_backend_count_get(void)
Get number of backends.
Definition: log_backend.h:265
static void log_backend_panic(const struct log_backend *const backend)
Reconfigure backend to panic mode.
Definition: log_backend.h:213
static uint8_t log_backend_id_get(const struct log_backend *const backend)
Get backend id.
Definition: log_backend.h:242
static const struct log_backend * log_backend_get(uint32_t idx)
Get backend.
Definition: log_backend.h:255
log_format_func_t log_format_func_t_get(uint32_t log_type)
Declaration of the get routine for function pointer table format_table.
#define EINVAL
Definition: errno.h:61
#define ENOTSUP
Definition: errno.h:115
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Logger backend API.
Definition: log_backend.h:33
void(* panic)(const struct log_backend *const backend)
Definition: log_backend.h:50
void(* put_sync_string)(const struct log_backend *const backend, struct log_msg_ids src_level, uint32_t timestamp, const char *fmt, va_list ap)
Definition: log_backend.h:41
void(* dropped)(const struct log_backend *const backend, uint32_t cnt)
Definition: log_backend.h:49
void(* process)(const struct log_backend *const backend, union log_msg2_generic *msg)
Definition: log_backend.h:35
void(* 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)
Definition: log_backend.h:44
void(* init)(const struct log_backend *const backend)
Definition: log_backend.h:51
int(* format_set)(const struct log_backend *const backend, uint32_t log_type)
Definition: log_backend.h:52
void(* put)(const struct log_backend *const backend, struct log_msg *msg)
Definition: log_backend.h:39
Logger backend control block.
Definition: log_backend.h:59
uint8_t id
Definition: log_backend.h:61
bool active
Definition: log_backend.h:62
void * ctx
Definition: log_backend.h:60
Logger backend structure.
Definition: log_backend.h:68
const char * name
Definition: log_backend.h:71
const struct log_backend_api * api
Definition: log_backend.h:69
struct log_backend_control_block * cb
Definition: log_backend.h:70
bool autostart
Definition: log_backend.h:72
Part of log message header identifying source and level.
Definition: log_msg.h:85
Log message structure.
Definition: log_msg.h:139
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
static void msg(uint64_t c64)
Definition: main.c:17
Definition: log_msg2.h:101