From a99a2e9866c475a0966619d69a8aa1a80d9910b3 Mon Sep 17 00:00:00 2001 From: "Edwards, Daniel" Date: Wed, 11 Oct 2023 08:21:46 +0200 Subject: [PATCH] -- remove usage of fmt::streamed in favor of explicit formatters for ostream-formattable types (#690) --- SilKit/source/services/logging/ILogger.hpp | 2 +- .../services/logging/SilKitFmtFormatters.hpp | 77 +++++++++++++++---- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/SilKit/source/services/logging/ILogger.hpp b/SilKit/source/services/logging/ILogger.hpp index 88f25c620..5fa72ff08 100644 --- a/SilKit/source/services/logging/ILogger.hpp +++ b/SilKit/source/services/logging/ILogger.hpp @@ -54,7 +54,7 @@ void Log(ILogger* logger, Level level, const char* fmt, const Args&... args) { if (logger && (logger->GetLogLevel() <= level)) { - const std::string msg = fmt::format(fmt, fmt::streamed(args)...); + const std::string msg = fmt::format(fmt, args...); logger->Log(level, msg); } diff --git a/SilKit/source/services/logging/SilKitFmtFormatters.hpp b/SilKit/source/services/logging/SilKitFmtFormatters.hpp index d2cca1d0c..e3a8e9d98 100755 --- a/SilKit/source/services/logging/SilKitFmtFormatters.hpp +++ b/SilKit/source/services/logging/SilKitFmtFormatters.hpp @@ -39,6 +39,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "ServiceDatatypes.hpp" #include "LoggingDatatypesInternal.hpp" +#include "RequestReplyDatatypes.hpp" + #include "WireCanMessages.hpp" #include "WireEthernetMessages.hpp" #include "WireFlexrayMessages.hpp" @@ -50,18 +52,63 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "IServiceEndpoint.hpp" // for operator<<(... ServiceDescriptor) -#define MAKE_FORMATTER(TYPE) template<> struct fmt::formatter : ostream_formatter{} -MAKE_FORMATTER( SilKit::Core::Discovery::ServiceDiscoveryEvent); -MAKE_FORMATTER( SilKit::Services::Lin::LinChecksumModel); -MAKE_FORMATTER( SilKit::Services::Lin::LinFrameResponseMode); -MAKE_FORMATTER( SilKit::Services::Rpc::FunctionCall); -MAKE_FORMATTER( SilKit::Services::Rpc::FunctionCallResponse); -MAKE_FORMATTER( SilKit::Services::Orchestration::ParticipantState); -MAKE_FORMATTER( SilKit::Core::ServiceDescriptor); -MAKE_FORMATTER( SilKit::Core::ProtocolVersion); -MAKE_FORMATTER( SilKit::Core::Discovery::ParticipantDiscoveryEvent); -MAKE_FORMATTER( SilKit::Services::PubSub::WireDataMessageEvent); -MAKE_FORMATTER( SilKit::Services::Logging::LogMsg); -MAKE_FORMATTER( SilKit::Services::Orchestration::WorkflowConfiguration); -MAKE_FORMATTER( SilKit::Services::Orchestration::SystemCommand); -MAKE_FORMATTER( SilKit::Services::Lin::LinControllerStatus); +#define MAKE_FORMATTER(TYPE) template<> struct fmt::formatter : ostream_formatter {} + + +MAKE_FORMATTER(SilKit::Services::Can::CanConfigureBaudrate); +MAKE_FORMATTER(SilKit::Services::Can::CanControllerStatus); +MAKE_FORMATTER(SilKit::Services::Can::CanFrameTransmitEvent); +MAKE_FORMATTER(SilKit::Services::Can::CanSetControllerMode); +MAKE_FORMATTER(SilKit::Services::Can::WireCanFrameEvent); + +MAKE_FORMATTER(SilKit::Services::Ethernet::EthernetFrameTransmitEvent); +MAKE_FORMATTER(SilKit::Services::Ethernet::EthernetSetMode); +MAKE_FORMATTER(SilKit::Services::Ethernet::EthernetStatus); +MAKE_FORMATTER(SilKit::Services::Ethernet::WireEthernetFrameEvent); + +MAKE_FORMATTER(SilKit::Services::Flexray::FlexrayControllerConfig); +MAKE_FORMATTER(SilKit::Services::Flexray::FlexrayCycleStartEvent); +MAKE_FORMATTER(SilKit::Services::Flexray::FlexrayHostCommand); +MAKE_FORMATTER(SilKit::Services::Flexray::FlexrayPocStatusEvent); +MAKE_FORMATTER(SilKit::Services::Flexray::FlexraySymbolEvent); +MAKE_FORMATTER(SilKit::Services::Flexray::FlexraySymbolTransmitEvent); +MAKE_FORMATTER(SilKit::Services::Flexray::FlexrayTxBufferConfigUpdate); +MAKE_FORMATTER(SilKit::Services::Flexray::WireFlexrayFrameEvent); +MAKE_FORMATTER(SilKit::Services::Flexray::WireFlexrayFrameTransmitEvent); +MAKE_FORMATTER(SilKit::Services::Flexray::WireFlexrayTxBufferUpdate); + +MAKE_FORMATTER(SilKit::Services::Lin::LinChecksumModel); +MAKE_FORMATTER(SilKit::Services::Lin::LinControllerConfig); +MAKE_FORMATTER(SilKit::Services::Lin::LinControllerMode); +MAKE_FORMATTER(SilKit::Services::Lin::LinControllerStatus); +MAKE_FORMATTER(SilKit::Services::Lin::LinControllerStatusUpdate); +MAKE_FORMATTER(SilKit::Services::Lin::LinFrameResponseMode); +MAKE_FORMATTER(SilKit::Services::Lin::LinFrameResponseUpdate); +MAKE_FORMATTER(SilKit::Services::Lin::LinSendFrameHeaderRequest); +MAKE_FORMATTER(SilKit::Services::Lin::LinSendFrameRequest); +MAKE_FORMATTER(SilKit::Services::Lin::LinTransmission); +MAKE_FORMATTER(SilKit::Services::Lin::LinWakeupPulse); +MAKE_FORMATTER(SilKit::Services::Lin::WireLinControllerConfig); + +MAKE_FORMATTER(SilKit::Services::Logging::LogMsg); + +MAKE_FORMATTER(SilKit::Services::Orchestration::NextSimTask); +MAKE_FORMATTER(SilKit::Services::Orchestration::ParticipantState); +MAKE_FORMATTER(SilKit::Services::Orchestration::ParticipantStatus); +MAKE_FORMATTER(SilKit::Services::Orchestration::SystemState); +MAKE_FORMATTER(SilKit::Services::Orchestration::SystemCommand); +MAKE_FORMATTER(SilKit::Services::Orchestration::WorkflowConfiguration); + +MAKE_FORMATTER(SilKit::Services::PubSub::WireDataMessageEvent); + +MAKE_FORMATTER(SilKit::Services::Rpc::FunctionCall); +MAKE_FORMATTER(SilKit::Services::Rpc::FunctionCallResponse); + + +MAKE_FORMATTER(SilKit::Core::ServiceDescriptor); +MAKE_FORMATTER(SilKit::Core::ProtocolVersion); +MAKE_FORMATTER(SilKit::Core::Discovery::ParticipantDiscoveryEvent); +MAKE_FORMATTER(SilKit::Core::Discovery::ServiceDiscoveryEvent); +MAKE_FORMATTER(SilKit::Core::Tests::TestMessage); +MAKE_FORMATTER(SilKit::Core::RequestReply::RequestReplyCall); +MAKE_FORMATTER(SilKit::Core::RequestReply::RequestReplyCallReturn);