Component Architecture#

mw::log Backend Architecture
status: draft
security: NO
safety: ASIL_B
bazel_module: score_logging
version: 1

Overview#

The mw::log Backend writes the log records created by the Log Frontend (score_baselibs) to an output channel: the Datarouter (remote/DLT), the system logger (syslog on Linux, slog on QNX), a local file or a custom backend.

Description#

The backends are selected in two steps. At build time, the application links the backends it needs, and each linked backend registers itself for a LogMode before main(). At runtime, the logging configuration of the application selects the LogMode values, and a recorder is created for each of them that has a registered backend.

A recorder turns the log calls of a LogStream into a log record, and its backend owns the slots that hold the records and writes a finished record to the output channel. The remote/DLT backend hands the records over to comp__datarouter through a shared-memory ring buffer (Log Record Shared-Memory (logic_arc_int__logging__shared_memory)) and uses a separate control channel to connect to it (Control Channel (logic_arc_int__logging__datarouter_msg_client)).

Design decisions:

  • Recorder and backend are separate abstractions, so a new output channel only needs a new backend.

  • Logging does not block the application: slots are reserved without time-unbound locks, and a record that does not fit is dropped and counted instead of waited for.

Design constraints:

  • Heap allocation only during initialization, local allocators afterwards.

  • Syslog backend on Linux only, slog backend on QNX only.

  • The file backend is not intended for production use (it uses a mutex to drain the slots).

  • Datarouter outputs shall not be relied upon for safety goals: sizes of shared-memory entries, messages and notifications are limited and checked.

The detailed design of the units is described in mw::log Backend Detailed De... (doc__mw_log_backend_detailed_design).

Rationale Behind Architecture Decomposition#

The component is not split into lower level components. It is decomposed into units by output channel (one recorder/backend pair per LogMode), so that each unit has a single responsibility and can be selected and tested independently. The units are described in the detailed design.

Note

Common decisions across components / cross cutting concepts is at the higher level.

Static Architecture#

mw::log Backend
status: valid
security: YES
safety: ASIL_B

This is the logging component library responsible for selecting the appropriate log sinks based on configuration at runtime. It can perform tasks such as log formatting, filtering, and composite backend selection based on runtime context and configuration. The logging component is designed to be extensible, allowing for custom logging backend to be added as needed.

Dynamic Architecture#

Log Call via DataRouter Recorder
status: valid
security: YES
safety: ASIL_B

One verbose log call in remote/DLT mode: the DataRouterRecorder reserves a slot, serializes the arguments in DLT verbose format and, when the LogStream is destroyed, flushes the record into the shared-memory ring buffer read by comp__datarouter. A disabled log level, a missing slot or an argument that does not fit are handled without blocking and are counted.

Connection Setup to Datarouter
status: valid
security: YES
safety: ASIL_B

The remote/DLT backend connects to comp__datarouter over the control channel in its own thread, so the application is not blocked while the Datarouter is not available. On a failure, the shared-memory file is unlinked and the client is stopped.

Log Call via System Backend
status: valid
security: NO
safety: QM
bazel_module: score_logging
version: 1

One log call in system mode on Linux: the TextRecorder formats the record into a slot of the SyslogBackend, which forwards it to the system logger (syslog(3)) when the slot is flushed.

Interfaces#

Log Record Shared-Memory
status: valid
security: YES
safety: ASIL_B
bazel_module: score_logging
version: 1

Shared-memory ring buffer carrying only serialized log records: the remote/DLT recorder backend writes into it, and comp__datarouter reads from it to route records onward to the network stack. Connection setup and buffer-acquire requests are not carried on this channel; see Control Channel (logic_arc_int__logging__datarouter_msg_client) for that.

Control Channel
status: valid
security: YES
safety: ASIL_B
bazel_module: score_logging
version: 1

mw::com message-passing session between the remote/DLT recorder and its source session inside comp__datarouter: used to initiate the connection and for comp__datarouter to send buffer-acquire requests back to the recorder. Carries no log record payload; see Log Record Shared-Memory (logic_arc_int__logging__shared_memory) for that.

Decision Records#

Explicit initialization of ... (dec_rec__logging__explicit_init)