Skip to content

Commit

Permalink
-- remove usage of fmt::streamed in favor of explicit formatters for …
Browse files Browse the repository at this point in the history
…ostream-formattable types (#690)
  • Loading branch information
VDanielEdwards authored and GitHub Enterprise committed Oct 11, 2023
1 parent bc9421c commit a99a2e9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 16 deletions.
2 changes: 1 addition & 1 deletion SilKit/source/services/logging/ILogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
77 changes: 62 additions & 15 deletions SilKit/source/services/logging/SilKitFmtFormatters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<TYPE> : 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<TYPE> : 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);

0 comments on commit a99a2e9

Please sign in to comment.