15#include <cppfmu_common.hpp>
16#include <fastdds/dds/log/OStreamConsumer.hpp>
20class FmiLogger :
public eprosima::fastdds::dds::OStreamConsumer {
23 FmiLogger(cppfmu::Logger& logger,
const std::string& name)
24 : m_logger(logger), m_str(std::ostringstream::ate), m_name(name) {}
27 void Consume(
const eprosima::fastdds::dds::Log::Entry& entry)
override {
28 eprosima::fastdds::dds::OStreamConsumer::Consume(entry);
30 cppfmu::FMIStatus status;
33 case eprosima::fastdds::dds::Log::Kind::Info:
34 status = cppfmu::FMIOK;
36 case eprosima::fastdds::dds::Log::Kind::Warning:
37 case eprosima::fastdds::dds::Log::Kind::Error:
38 status = cppfmu::FMIWarning;
43 m_logger.Log(status, m_name.c_str(), m_str.str().c_str());
49 std::ostream&
get_stream(
const eprosima::fastdds::dds::Log::Entry& entry)
override {
54 std::ostringstream m_str;
56 cppfmu::Logger& m_logger;
Definition: LoggerAdapters.hpp:20
virtual ~FmiLogger()=default
void Consume(const eprosima::fastdds::dds::Log::Entry &entry) override
Definition: LoggerAdapters.hpp:27
std::ostream & get_stream(const eprosima::fastdds::dds::Log::Entry &entry) override
Definition: LoggerAdapters.hpp:49
FmiLogger(cppfmu::Logger &logger, const std::string &name)
Definition: LoggerAdapters.hpp:23
Definition: auxiliaries.cpp:26