DEENESPTFRRUARHIKOZHNL

struct ara::log::Format

[SWS_LOG_00207] Upstream: RS_LT_00046

struct Format final {...};

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.

Header-Datei#include "ara/log/logger.h"
Forwarding-Header#include "ara/log/log_fwd.h"
Scopenamespace ara::log

User GuideAI-GENERATED

Serves as a formatting hint to control display format and precision when outputting log values.
AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: ae5714d3cea4 Provenance Open 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.
FormatAuswertung start Format-Auswertung check_fmt Welcher Typ in fmt? start->check_fmt integral precision == 0? check_fmt->integral kDec, kOct, kHex, kBin float_fixed Exakte Nachkommastellen = precision check_fmt->float_fixed kDecFloat, kEngFloat, kHexFloat float_auto Signifikante Stellen = precision (analog %g) check_fmt->float_auto kAutoFloat default_fmt precision ignoriert (Standardformatierung) check_fmt->default_fmt kDefault integral_min Minimale Stellenanzahl = precision integral->integral_min no integral_one Minimale Stellenanzahl = 1 integral->integral_one yes end Formatierung angewendet integral_min->end integral_one->end float_fixed->end float_auto->end default_fmt->end

Activity diagram: Branching logic for evaluating precision depending on fmt. Sources: [SWS_LOG_00225], [SWS_LOG_00226]

Error Scenarios

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.

G nara__log__Format351 «struct» Format + fmt + precision

Constants

fmt variable

the format specifier

Fmt fmt;
precision variable

the precision to use

std::uint16_t precision;

Documentation of constants / variables

variable fmt [SWS_LOG_00225] Upstream: RS_LT_00046

Fmt fmt;

the format specifier

Header-Datei#include "ara/log/logger.h"
Scopestruct ara::log::Format
Symbolfmt
TypFmt

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_LOG_00225
Status
valid/auto-approved
Version
AUTOSAR/AP/record/SWS_LOG_00225@rel:R25-11#637a0dc2
Content hash
637a0dc2
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_LogAndTrace.pdf#nameddest=SWS_LOG_00225
Status: valid/auto-approved Version: rel:R25-11#04613a79 Versionshistorie & Revisions (2 transitions, 6 revision)
Current State
valid/auto-approved
Reason
unchanged
Campaign
2026-08-sws-log-pilot-after-tool-improvement
Active Version
AUTOSAR/AP/record/SWS_LOG_00225@rel:R25-11#04613a79
Point-in-Time History:
Recorded Revisions (6):
  • R25-11rel:R25-11#637a0dc22026-09-30
  • R21-11rel:R21-11#b0525fe12026-10-14
  • R22-11rel:R22-11#81b856192026-10-14
  • R23-11rel:R23-11#04613a792026-10-14
  • R24-11rel:R24-11#04613a792026-10-14
  • R25-11rel:R25-11#04613a792026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-10toolvalid/unversioned → invalid/obsoletespec update after tool improvement2026-08-sws-log-pilot-after-tool-improvement
2026-08-10toolinvalid/obsolete → valid/auto-approvedunchanged2026-08-sws-log-pilot-after-tool-improvement

variable precision [SWS_LOG_00226] Upstream: RS_LT_00046

std::uint16_t precision;

the precision to use

Header-Datei#include "ara/log/logger.h"
Scopestruct ara::log::Format
Symbolprecision
Typstd::uint16_t

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_LOG_00226
Status
valid/auto-approved
Version
AUTOSAR/AP/record/SWS_LOG_00226@rel:R25-11#ee318034
Content hash
ee318034
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_LogAndTrace.pdf#nameddest=SWS_LOG_00226
Status: valid/auto-approved Version: rel:R25-11#c555de85 Versionshistorie & Revisions (2 transitions, 6 revision)
Current State
valid/auto-approved
Reason
unchanged
Campaign
2026-08-sws-log-pilot-after-tool-improvement
Active Version
AUTOSAR/AP/record/SWS_LOG_00226@rel:R25-11#c555de85
Point-in-Time History:
Recorded Revisions (6):
  • R25-11rel:R25-11#ee3180342026-09-30
  • R21-11rel:R21-11#c847203d2026-10-14
  • R22-11rel:R22-11#406eff9e2026-10-14
  • R23-11rel:R23-11#c555de852026-10-14
  • R24-11rel:R24-11#c555de852026-10-14
  • R25-11rel:R25-11#c555de852026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-10toolvalid/unversioned → invalid/obsoletespec update after tool improvement2026-08-sws-log-pilot-after-tool-improvement
2026-08-10toolinvalid/obsolete → valid/auto-approvedunchanged2026-08-sws-log-pilot-after-tool-improvement