A type holding a formatting hint. The interpretation of precision depends on fmt: For integral types (i.e. Fmt::kDec, Fmt::kOct, Fmt::kHex, Fmt::kBin), precision is interpreted as the minimum number of digits to output, similar to e.g. std::printf("%.7d"). For the floating-point specifiers Fmt::kDecFloat, Fmt::kEngFloat and Fmt::kHexFloat, precision denotes the exact number of digits to be shown after the decimal point; for Fmt::kAutoFloat, precision denotes the number of significant digits to be shown according to the rules of the std::printf "%g" specifier. If fmt is Fmt::kDefault, the precision field is ignored, and an implementation-defined formatting is applied. For integral types, if precision is 0, it is interpreted the same as if it was 1. For convenience, there are helper functions to create specific instances of this struct. The helper functions should be used instead of creating instances manually.
Serves as a formatting hint to control display format and precision when outputting log values.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: ae5714d3cea4ProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Serves as a formatting hint to control display format and precision when outputting log values.
Structure ara::log::Format serves as a formatting hint in the logging system and bundles format specifier fmt ([SWS_LOG_00225]) with precision specification precision ([SWS_LOG_00226]). Instances should preferably be created via provided helper functions, with the evaluation of precision distinguishing between minimum number of digits for integers and decimal places for floating-point numbers depending on the format type. For integer types, a precision of zero is treated like one, while the field is completely ignored under Fmt::kDefault.
Context
Data structure ara::log::Format serves in the logging framework of the AUTOSAR Adaptive Platform as a formatting hint for outputting formatted values. For this purpose, it bundles two central properties: format specification fmt of enumeration type Fmt ([SWS_LOG_00225]) and the associated precision precision as std::uint16_t ([SWS_LOG_00226]). Interaction partners are output components and formatting streams of the logging module as well as the application logic that creates log messages with formatted text output. Interpretation: The helper functions mentioned in the specification for instantiation are likely located directly in module ara::log to provide standardized formatters. Question Q-1c465e69c99359fa (open)
Lifecycle
As a final data structure (struct Format final), ara::log::Format has no internal state machine and no complex phase transitions. Although the attributes are declared as public variables ([SWS_LOG_00225], [SWS_LOG_00226]), the specification explicitly requires not creating instances manually, but instead using the provided helper functions. Instances are typically short-lived value objects that are passed to log streams by copy or by reference. Interpretation: Since the structure exhibits no internal synchronization, copies and concurrent read accesses across thread boundaries are likely thread-safe, whereas mutating accesses must be synchronized externally. Question Q-bd0f1147e9472c19 (open)
Usage Path
Typical usage includes defining the format specifier fmt ([SWS_LOG_00225]) and specifying the desired precision precision ([SWS_LOG_00226]). The evaluation of precision depends on the selected type in fmt:
Integer types: For Fmt::kDec, Fmt::kOct, Fmt::kHex, and Fmt::kBin, precision designates the minimum number of digits to be output, analogous to formatting via std::printf("%.7d").
Floating-point types with fixed-point and exponential representation: For Fmt::kDecFloat, Fmt::kEngFloat, and Fmt::kHexFloat, precision specifies the exact number of decimal places.
Automatic floating-point representation: Under Fmt::kAutoFloat, precision defines the number of significant digits according to the rules of the format specifier %g in std::printf.
Default formatting: If fmt holds the value Fmt::kDefault, the specification in precision is ignored and implementation-defined formatting is applied.
The structure does not define any error codes or exceptions; edge cases are instead handled fault-tolerantly and deterministically. For integer format specifiers (Fmt::kDec, Fmt::kOct, Fmt::kHex, Fmt::kBin), a value of precision = 0 ([SWS_LOG_00226]) is evaluated semantically identically to a value of 1 to prevent blank outputs. If fmt is set to Fmt::kDefault ([SWS_LOG_00225]), a set value in precision does not lead to an error state, but is silently discarded.
This guide is based on the requirements of the specification for the logging module of AUTOSAR Adaptive Platform R25-11.
UML class diagram
Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.
gemini-3.8-flash-low· 2026-10-13 · German original