Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_log.h
Go to the documentation of this file.
1
19#ifndef RTE_OS_LOG_H
20#define RTE_OS_LOG_H
21
24#include "rte/utils/string/rte_string.h" /* rte_log_fields_t backing store */
25
26#include <stdbool.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
40
49
58void rte_log_write(rte_log_level_t level, const char *tag, const char *message);
59
73
85rte_status_t rte_log_level_from_string(const char *name, rte_log_level_t *out_level);
86
107void rte_log_set_level(rte_log_level_t min_level);
108
114
122#define RTE_LOG_EVENT_LINE_MAX_LEN 256U
123
201 const char *site,
202 uint32_t cycle,
203 const char *source,
204 const char *destination,
205 const char *type,
206 const char *info,
207 const char *extra_fields);
208
231typedef struct rte_log_fields_s
232{
236
245
261rte_log_fields_t *rte_log_fields_add_str(rte_log_fields_t *fields, const char *key, const char *value);
262rte_log_fields_t *rte_log_fields_add_u32(rte_log_fields_t *fields, const char *key, uint32_t value);
263rte_log_fields_t *rte_log_fields_add_i32(rte_log_fields_t *fields, const char *key, int32_t value);
264rte_log_fields_t *rte_log_fields_add_u64(rte_log_fields_t *fields, const char *key, uint64_t value);
265rte_log_fields_t *rte_log_fields_add_i64(rte_log_fields_t *fields, const char *key, int64_t value);
266rte_log_fields_t *rte_log_fields_add_hex_u32(rte_log_fields_t *fields, const char *key,
267 uint32_t value, uint8_t min_digits);
268rte_log_fields_t *rte_log_fields_add_bool(rte_log_fields_t *fields, const char *key, bool value);
270
280const char *rte_log_fields_c_str(rte_log_fields_t *fields);
281
292 const char *site,
293 uint32_t cycle,
294 const char *source,
295 const char *destination,
296 const char *type,
297 const char *info,
298 rte_log_fields_t *fields);
299
300/*
301 * The OSAdapter vtable (rte_osadapter_log_t) and rte_osadapter_log_register()
302 * live in rte_osadapter/log/rte_osadapter_log.h, not here (ADR-021).
303 * This header is the consumer-facing surface only.
304 */
305
306#ifdef __cplusplus
307}
308#endif
309
310#endif /* RTE_OS_LOG_H */
311 /* LOG */
void rte_log_set_level(rte_log_level_t min_level)
Sets the minimum severity that rte_log_write() and rte_log_write_event() forward to the OSAdapter - a...
Definition rte_log.c:146
rte_status_t rte_log_level_from_string(const char *name, rte_log_level_t *out_level)
Parses one of the canonical level spellings ("DEBUG", "INFO", "WARNING", "ERROR" - exactly as rte_log...
Definition rte_log.c:125
void rte_log_write_event(rte_log_level_t level, const char *site, uint32_t cycle, const char *source, const char *destination, const char *type, const char *info, const char *extra_fields)
Emits one structured inter-channel event/message-trail log line - for a message actually sent/receive...
Definition rte_log.c:188
rte_log_level_t rte_log_get_level(void)
Returns the current minimum severity (see rte_log_set_level()). REQ-OAL-LOG-015.
Definition rte_log.c:157
rte_log_fields_t * rte_log_fields_add_str(rte_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 rte_log.c:285
const char * rte_log_level_to_string(rte_log_level_t level)
Renders a rte_log_level_t as a fixed, human-readable tag - "DEBUG"/"INFO"/"WARNING"/"ERROR" - used as...
Definition rte_log.c:162
const char * rte_log_fields_c_str(rte_log_fields_t *fields)
NUL-terminated view of the accumulated pairs.
Definition rte_log.c:350
rte_log_level_t
Log message severity, passed to rte_log_write().
Definition rte_log.h:34
#define RTE_LOG_EVENT_LINE_MAX_LEN
Max length, in bytes and not counting the NUL terminator, of one rte_log_write_event() line - fields ...
Definition rte_log.h:122
void rte_log_fields_reset(rte_log_fields_t *fields)
(Re)initialises a builder to empty. MUST be called before the first rte_log_fields_add_*(); safe to c...
Definition rte_log.c:254
rte_status_t rte_log_init(void)
Initializes the logging OSAdapter. Safe to call once at startup.
Definition rte_log.c:99
void rte_log_write(rte_log_level_t level, const char *tag, const char *message)
Emits one log message. Non-blocking; never fails the caller's control flow even if the message is dro...
Definition rte_log.c:108
void rte_log_write_event_fields(rte_log_level_t level, const char *site, uint32_t cycle, const char *source, const char *destination, const char *type, const char *info, rte_log_fields_t *fields)
rte_log_write_event() with a builder passed directly as the extra fields - no rte_log_fields_c_str() ...
Definition rte_log.c:366
@ RTE_LOG_LEVEL_DEBUG
Definition rte_log.h:35
@ RTE_LOG_LEVEL_INFO
Definition rte_log.h:36
@ RTE_LOG_LEVEL_WARNING
Definition rte_log.h:37
@ RTE_LOG_LEVEL_ERROR
Definition rte_log.h:38
rte_status_t
Common result/status codes.
Definition rte_status.h:27
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Bounded, checked string manipulation (ADR-006). Replaces strcpy/strcat/sprintf/atoi/strtok-style unbo...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
Bounded builder for rte_log_write_event()'s extra_fields (or info) argument: accumulates space-separa...
Definition rte_log.h:232
char storage[RTE_LOG_EVENT_LINE_MAX_LEN]
Definition rte_log.h:234
rte_string_t str
Definition rte_log.h:233
Bounded string: buf.length is the string length, not counting a NUL.
Definition rte_string.h:39