Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
sapi_log_fields_t Struct Reference

Bounded builder for sapi_log_write_event()'s extra_fields (or info) argument: accumulates space-separated key=value pairs, each typed at the call site, so a caller adding a couple of variable values does not hand-roll a sapi_string_concat()/sapi_string_append_u32() chain every time (MISRA C:2012 Rule 17.1 rules out a printf-style variadic here). More...

#include <sapi_log.h>

Collaboration diagram for sapi_log_fields_t:
[legend]

Data Fields

sapi_string_t str
char storage [SAPI_LOG_EVENT_LINE_MAX_LEN]

Detailed Description

Bounded builder for sapi_log_write_event()'s extra_fields (or info) argument: accumulates space-separated key=value pairs, each typed at the call site, so a caller adding a couple of variable values does not hand-roll a sapi_string_concat()/sapi_string_append_u32() chain every time (MISRA C:2012 Rule 17.1 rules out a printf-style variadic here).

All storage is inside the struct - no allocation. Over-long content is truncated, never rejected, matching sapi_log_write_event()'s own REQ-OAL-LOG-001 posture. Typical use:

sapi_log_fields_add_u32(&f, "route", route_id);
sapi_log_fields_add_i32(&f, "d_lrbg", d_lrbg);
sapi_log_fields_add_str(&f, "result", "OK");
"A/WEST", "IL", "ROUTE", "route connected", &f);
void sapi_log_write_event_fields(sapi_log_level_t level, const char *site, uint32_t cycle, const char *source, const char *destination, const char *type, const char *info, sapi_log_fields_t *fields)
sapi_log_write_event() with a builder passed directly as the extra fields - no sapi_log_fields_c_str(...
Definition sapi_log.c:366
void sapi_log_fields_reset(sapi_log_fields_t *fields)
(Re)initialises a builder to empty. MUST be called before the first sapi_log_fields_add_*(); safe to ...
Definition sapi_log.c:254
sapi_log_fields_t * sapi_log_fields_add_str(sapi_log_fields_t *fields, const char *key, const char *value)
Appends one key=value pair (preceded by a single separating space only when the builder is already no...
Definition sapi_log.c:285
@ SAPI_LOG_LEVEL_INFO
Definition sapi_log.h:36
Bounded builder for sapi_log_write_event()'s extra_fields (or info) argument: accumulates space-separ...
Definition sapi_log.h:232

Definition at line 231 of file sapi_log.h.

Field Documentation

◆ str

sapi_string_t sapi_log_fields_t::str

Bound to storage by sapi_log_fields_reset().

Definition at line 233 of file sapi_log.h.

◆ storage

char sapi_log_fields_t::storage[SAPI_LOG_EVENT_LINE_MAX_LEN]

Backing bytes - do not touch directly.

Definition at line 234 of file sapi_log.h.


The documentation for this struct was generated from the following file: