|
| rte_status_t | rte_log_init (void) |
| | Initializes the logging OSAdapter. Safe to call once at startup.
|
| 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 dropped.
|
| 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 the LEVEL field of rte_log_write_event()'s structured line and available to any OSAdapter/integrator wanting the same canonical spelling.
|
| 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_level_to_string() renders them, case-sensitive) into a rte_log_level_t.
|
| 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 call whose level is below min_level is dropped before dispatch (and before any formatting work). Default is RTE_LOG_LEVEL_DEBUG: nothing is filtered until this is called.
|
| rte_log_level_t | rte_log_get_level (void) |
| | Returns the current minimum severity (see rte_log_set_level()). REQ-OAL-LOG-015.
|
| 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/received/decided between channels or nodes (e.g. an AB_SAMPLE frame, an M136 report, a checkpoint REQUEST/REPLY, a cross-compare AGREE/DISAGREE) - distinct from rte_log_write()'s free-text diagnostic logging, which remains the right call for an event with no natural cycle/source/destination (e.g. an NVM write failure).
|
| 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 call again to reuse the same builder for another line.
|
| const char * | rte_log_fields_c_str (rte_log_fields_t *fields) |
| | NUL-terminated view of the accumulated pairs.
|
| 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() at the call site.
|
| 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 non-empty).
|
| rte_log_fields_t * | rte_log_fields_add_u32 (rte_log_fields_t *fields, const char *key, uint32_t value) |
| rte_log_fields_t * | rte_log_fields_add_i32 (rte_log_fields_t *fields, const char *key, int32_t value) |
| rte_log_fields_t * | rte_log_fields_add_u64 (rte_log_fields_t *fields, const char *key, uint64_t value) |
| rte_log_fields_t * | rte_log_fields_add_i64 (rte_log_fields_t *fields, const char *key, int64_t value) |
| rte_log_fields_t * | rte_log_fields_add_hex_u32 (rte_log_fields_t *fields, const char *key, uint32_t value, uint8_t min_digits) |
| rte_log_fields_t * | rte_log_fields_add_bool (rte_log_fields_t *fields, const char *key, bool value) |
Non-safety-related black-box/event-recorder logging (ADR-001).
Sets the minimum severity that rte_log_write() and rte_log_write_event() forward to the OSAdapter - a call whose level is below min_level is dropped before dispatch (and before any formatting work). Default is RTE_LOG_LEVEL_DEBUG: nothing is filtered until this is called.
Runtime-settable so an integrator can quiet or open up logging without a rebuild (e.g. a remote "set log level" command). NOT a setup-only action (unlike rte_osadapter_log_register()) - may be called at any time, from any thread: the threshold is one int-sized value, so a concurrent change racing an in-flight rte_log_write() only ever means that one call sees the old or the new threshold, never a torn value, and at worst one best-effort log line is kept or dropped unexpectedly (REQ-OAL-LOG-001).
- Parameters
-
| min_level | Lowest level to keep. A value outside RTE_LOG_LEVEL_DEBUG..RTE_LOG_LEVEL_ERROR is ignored (the current threshold is left unchanged). REQ-OAL-LOG-015 |
Definition at line 146 of file rte_log.c.
| 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/received/decided between channels or nodes (e.g. an AB_SAMPLE frame, an M136 report, a checkpoint REQUEST/REPLY, a cross-compare AGREE/DISAGREE) - distinct from rte_log_write()'s free-text diagnostic logging, which remains the right call for an event with no natural cycle/source/destination (e.g. an NVM write failure).
Emits, via the same OSAdapter as rte_log_write() (non-blocking, best-effort, same REQ-OAL-LOG-001 contract - a full OSAdapter buffer or an unregistered OSAdapter silently drops this call, never blocks or errors the caller):
Site=<site> Timestamp=<ms> Level=<LEVEL> Cycle=<n> Source=<src> Destination=<dst> Type=<type> Info=<info>[ <extra_fields>]
i.e. space-separated Key=Value pairs, one per mandatory field, in that fixed order, as the message argument of the registered rte_osadapter_log_t::write(), with source passed as that call's tag argument - an existing OSAdapter needs no changes to receive structured events (e.g. the shipped POSIX OSAdapter still prefixes its own "[LEVEL] tag: " for terminal readability; a consumer parsing the structured Key=Value fields should parse from the message value itself, not whatever cosmetic wrapping a specific OSAdapter adds around it).
Timestamp is sourced internally via rte_timer_now() (milliseconds); "0" is emitted if no rte_timer OSAdapter is registered or the call otherwise fails - REQ-OAL-LOG-001 means a timer problem must never prevent this call from returning, so a timestamp failure degrades the Timestamp field rather than skipping the whole event.
- Parameters
-
| level | Severity. |
| site | Caller-supplied node/site/instance identifier (e.g. "WEST", "EAST") - the framework has no concept of a "site" itself; this is opaque, caller-defined text, first in the emitted line so a log consumer merging output from multiple redundant instances can always tell them apart at a glance. Must not be NULL; pass "" if this integration has no such concept. |
| cycle | Cycle/iteration counter this event belongs to (e.g. rte_appmanager_state_t::iteration_count). Use 0 if this event has no natural cycle. |
| source | Short identifier of the event's origin (e.g. "A/WEST"). Must not be NULL; pass "" if unknown. |
| destination | Short identifier of the event's target (e.g. "B", "C", "-" for no specific destination). Must not be NULL. |
| type | Short event/message-type tag (e.g. "AB_SAMPLE", "M136", "CHECKPOINT_REQUEST", "AGREE"). Must not be NULL. |
| info | Free-text human-readable detail. May be NULL (an empty Info= value is emitted). |
| extra_fields | Optional, caller-preformatted additional Key=Value text (e.g. "D_LRBG=42 CRC=OK"), appended verbatim after Info=... behind one separating space - not wrapped in another key, so it reads as more of the same space-separated Key=Value convention. May be NULL (omitted entirely - no trailing space is emitted either). |
- Note
- Fixed arity, no variadic/<stdarg.h> (MISRA C:2012 Rule 17.1) - the single extra_fields parameter is how a caller adds more than the eight mandatory fields; build it first with rte::string's bounded helpers (rte_string_concat() etc.), the same primitives this function uses internally.
-
Every field is truncated, not rejected, if the internal fixed-size line buffer (RTE_LOG_EVENT_LINE_MAX_LEN) is too small for the full line - consistent with REQ-OAL-LOG-001's "never affect caller control flow"; there is no error return (this function returns void, like rte_log_write()). REQ-OAL-LOG-014
Definition at line 188 of file rte_log.c.