Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1b8d3a0
test topics
VLukasBecker Mar 13, 2026
f2f0cc6
Add topics in log message
VLukasBecker Mar 18, 2026
e4fe2ad
fixup! Add topics in log message
VLukasBecker Mar 24, 2026
2ee3a48
fixup! Add topics in log message
VLukasBecker Mar 25, 2026
7e7ee9d
Roll out the new internal logger interface
VLukasBecker Apr 8, 2026
289d66b
7e7ee9d35eacfc17c6e5be8b2018f52fdf3d138f
VLukasBecker Apr 9, 2026
29f3bf6
fixup! Roll out the new internal logger interface
VLukasBecker Apr 13, 2026
a0d24d7
Upgrade logging in asio component
VLukasBecker Apr 13, 2026
0ff32f4
fixup! Upgrade logging in asio component
VLukasBecker Apr 14, 2026
f51e979
Roll out the new internal logger interface
VLukasBecker Apr 15, 2026
651a051
Roll out new logger interface in network controller
VLukasBecker Apr 16, 2026
dfaadd8
Roll out new logger interface in tracing component
VLukasBecker Apr 16, 2026
34540c1
fixup! fixup! Upgrade logging in asio component
VLukasBecker Apr 16, 2026
51f0bb8
fixup! fixup! Upgrade logging in asio component
VLukasBecker Apr 16, 2026
e339ca2
fixup! fixup! Upgrade logging in asio component
VLukasBecker Apr 16, 2026
39d9a9d
Roll out new logger interface in dashboard component
VLukasBecker Apr 16, 2026
f4e3bc9
Roll out new logger interface in metrics component
VLukasBecker Apr 16, 2026
af977a1
Roll out new logger interface in network simulator component
VLukasBecker Apr 16, 2026
9c46c60
Cleaning and missing roll out
VLukasBecker Apr 16, 2026
eaa18ac
Cleanups and fixes
VLukasBecker Apr 20, 2026
04816b6
Fix, update missing logger calls
VLukasBecker Apr 21, 2026
fb1baa7
Fix, clean public logger interface
VLukasBecker Apr 21, 2026
6a0d2ef
Fix review requests
VLukasBecker Apr 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions SilKit/include/silkit/services/logging/LoggingDatatypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ enum class Level : uint32_t
Off = 0xffffffff //!< Logging is disabled
};

/*! \brief Topic of a log message
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enum should also be moved to the internal code.

*/
enum class Topic : uint32_t
{
None = 0, //!< Log message without topic
User = 1, //!< Log message of the SIL Kit user
LifeCycle = 2, //!< Log message of the lifecycle
SystemState = 3, //!< Log message of the system state
MessageTracing = 4, //!< Log message of the message tracing
ServiceDiscovery = 5, //!< Log message of the service discovery
Asio = 6, //!< Log message of the asio
TimeSync = 7, //!< Log message of the time sync service
Participant = 8, //!< Log message of the participant
TimeConfig = 9,
RequestReply = 10,
SystemMonitor = 11,
Controller = 12,
Tracing = 13,
Metrics = 14,
Dashboard = 15,
NetSim = 16,
Invalid = 0xffffffff //!< Invalid log message topic
};


} // namespace Logging
} // namespace Services
} // namespace SilKit
120 changes: 119 additions & 1 deletion SilKit/include/silkit/services/logging/string_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ inline std::string to_string(const Level& level);
inline Level from_string(const std::string& levelStr);
inline std::ostream& operator<<(std::ostream& out, const Level& level);

// ================================================================================
inline std::string to_string(const Topic& topic);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string-conversions should also be moved to the internal code.

inline Topic from_topic_string(const std::string& topicStr);
inline std::ostream& operator<<(std::ostream& out, const Topic& topic);
//inline bool operator== (const Topic& lhs, const Topic& rhs);
// ================================================================================
// Inline Implementations
// ================================================================================

Expand Down Expand Up @@ -84,6 +88,120 @@ inline Level from_string(const std::string& levelStr)
return Level::Off;
}


std::string to_string(const Topic& topic)
{
std::stringstream outStream;
outStream << topic;
return outStream.str();
}

std::ostream& operator<<(std::ostream& outStream, const Topic& topic)
{
switch (topic)
{
case Topic::User:
outStream << "User";
break;
case Topic::TimeSync:
outStream << "TimeSync";
break;
case Topic::LifeCycle:
outStream << "LifeCycle";
break;
case Topic::SystemState:
outStream << "SystemState";
break;
case Topic::MessageTracing:
outStream << "MessageTracing";
break;
case Topic::ServiceDiscovery:
outStream << "ServiceDiscovery";
break;
case Topic::Participant:
outStream << "Participant";
break;
case Topic::Asio:
outStream << "Asio";
break;
case Topic::TimeConfig:
outStream << "TimeConfig";
break;
case Topic::RequestReply:
outStream << "RequestReply";
break;
case Topic::SystemMonitor:
outStream << "SystemMonitor";
break;
case Topic::Controller:
outStream << "Controller";
break;
case Topic::Tracing:
outStream << "Tracing";
break;
case Topic::Metrics:
outStream << "Metrics";
break;
case Topic::Dashboard:
outStream << "Dashboard";
break;
case Topic::NetSim:
outStream << "NetSim";
break;
case Topic::None:
outStream << "None";
break;
default:
outStream << "Invalid";
}
return outStream;
}

inline Topic from_topic_string(const std::string& topicStr)
{
auto topic = SilKit::Util::LowerCase(topicStr);
if (topic == "none")
return Topic::None;
if (topic == "user")
return Topic::User;
if (topic == "timesync")
return Topic::TimeSync;
if (topic == "lifecycle")
return Topic::LifeCycle;
if (topic == "systemstate")
return Topic::SystemState;
if (topic == "messagetracing")
return Topic::MessageTracing;
if (topic == "servicediscovery")
return Topic::ServiceDiscovery;
if (topic == "participant")
return Topic::Participant;
if (topic == "timeconfig")
return Topic::TimeConfig;
if (topic == "asio")
return Topic::Asio;
if (topic == "requestreply")
return Topic::RequestReply;
if (topic == "systemmonitor")
return Topic::SystemMonitor;
if (topic == "controller")
return Topic::Controller;
if (topic == "tracing")
return Topic::Tracing;
if (topic == "metrics")
return Topic::Metrics;
if (topic == "netsim")
return Topic::NetSim;
if (topic == "dashboard")
return Topic::Dashboard;
return Topic::Invalid;
}
/*
inline bool operator==(const Topic& lhs, const Topic& rhs)
{
return static_cast<int>(lhs) == static_cast<int>(rhs);
}*/

} // namespace Logging
} // namespace Services
} // namespace SilKit
10 changes: 6 additions & 4 deletions SilKit/source/capi/CapiLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

#include "silkit/capi/SilKit.h"
#include "silkit/SilKit.hpp"
#include "silkit/services/logging/ILogger.hpp"

#include "ILoggerInternal.hpp"
#include "CapiImpl.hpp"

#include <string>
Expand All @@ -17,10 +16,13 @@ try
ASSERT_VALID_POINTER_PARAMETER(self);
ASSERT_VALID_POINTER_PARAMETER(message);

auto logger = reinterpret_cast<SilKit::Services::Logging::ILogger*>(self);
auto loggerPublic = reinterpret_cast<SilKit::Services::Logging::ILogger*>(self);
auto logger = dynamic_cast<SilKit::Services::Logging::ILoggerInternal*>(loggerPublic);
auto enumLevel = static_cast<SilKit::Services::Logging::Level>(level);
auto topic = SilKit::Services::Logging::Topic::User;

std::string useString{message}; //ensure we do not trigger the FMT template overload for const char*
logger->Log(enumLevel, useString);
logger->Log(enumLevel, topic, useString);
return SilKit_ReturnCode_SUCCESS;
}
CAPI_CATCH_EXCEPTIONS
Expand Down
7 changes: 7 additions & 0 deletions SilKit/source/capi/Test_CapiLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ class MockLogger : public SilKit::Services::Logging::ILogger
{
public:
MOCK_METHOD2(Log, void(Level, const std::string&));
MOCK_METHOD(void, Log, (Level, Topic, const std::string&), ());
MOCK_METHOD1(Trace, void(const std::string&));
MOCK_METHOD(void, Trace, (Topic, const std::string&), ());
MOCK_METHOD1(Debug, void(const std::string&));
MOCK_METHOD(void, Debug, (Topic, const std::string&), ());
MOCK_METHOD1(Info, void(const std::string&));
MOCK_METHOD(void, Info, (Topic, const std::string&), ());
MOCK_METHOD1(Warn, void(const std::string&));
MOCK_METHOD(void, Warn, (Topic, const std::string&), ());
MOCK_METHOD1(Error, void(const std::string&));
MOCK_METHOD(void, Error, (Topic, const std::string&), ());
MOCK_METHOD1(Critical, void(const std::string&));
MOCK_METHOD(void, Critical, (Topic, const std::string&), ());

MOCK_CONST_METHOD0(GetLogLevel, Level());
};
Expand Down
2 changes: 2 additions & 0 deletions SilKit/source/config/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ struct Sink
Type type{Type::Remote};
Services::Logging::Level level{Services::Logging::Level::Info};
std::string logName;
std::vector<Services::Logging::Topic> disabledTopics{};
std::vector<Services::Logging::Topic> enabledTopics{};
};

//! \brief Logger service
Expand Down
12 changes: 12 additions & 0 deletions SilKit/source/config/ParticipantConfiguration.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,18 @@
"type": "string",
"enum": [ "Simple", "Json" ]
},
"DisabledTopics": {
"type": "array",
"items": {
"type": "string"
}
},
"EnabledTopics": {
"type": "array",
"items": {
"type": "string"
}
},
"Level": {
"type": "string",
"enum": [
Expand Down
24 changes: 22 additions & 2 deletions SilKit/source/config/YamlReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
#include "YamlReader.hpp"

#include "silkit/services/logging/string_utils.hpp"
namespace VSilKit {

void YamlReader::Read(SilKit::Services::MatchingLabel& value)
Expand All @@ -24,7 +24,6 @@ void YamlReader::Read(SilKit::Services::MatchingLabel::Kind& value)
throw MakeConfigurationError("MatchingLabel::Kind should be an integer of Mandatory(2)|Optional(1).");
}


void YamlReader::Read(SilKit::Services::Logging::Level& obj)
{
if (IsString("Critical"))
Expand All @@ -47,6 +46,25 @@ void YamlReader::Read(SilKit::Services::Logging::Level& obj)
}
}

void YamlReader::Read(SilKit::Services::Logging::Topic& obj)
{
if (!IsScalar() )
{
throw MakeConfigurationError("Topic should be a string.");
}

std::string value;
Read(value);

const auto topic = SilKit::Services::Logging::from_topic_string(value);

if (topic == SilKit::Services::Logging::Topic::Invalid)
{
throw MakeConfigurationError("Unknown SilKit::Services::Logging::Topic");
}
obj = topic;
}

void YamlReader::Read(SilKit::Services::Flexray::FlexrayClusterParameters& obj)
{
// Parse parameters as an int value; uint8_t would be interpreted as a character
Expand Down Expand Up @@ -195,6 +213,8 @@ void YamlReader::Read(SilKit::Config::Sink& obj)
OptionalRead(obj.type, "Type");
OptionalRead(obj.level, "Level");
OptionalRead(obj.format, "Format");
OptionalRead(obj.disabledTopics, "DisabledTopics");
OptionalRead(obj.enabledTopics, "EnabledTopics");

if (obj.type == SilKit::Config::Sink::Type::File)
{
Expand Down
1 change: 1 addition & 0 deletions SilKit/source/config/YamlReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ struct YamlReader : BasicYamlReader<YamlReader>
void Read(SilKit::Services::MatchingLabel& value);
void Read(SilKit::Services::MatchingLabel::Kind& value);
void Read(SilKit::Services::Logging::Level& obj);
void Read(SilKit::Services::Logging::Topic& obj);
void Read(SilKit::Services::Flexray::FlexrayClusterParameters& obj);
void Read(SilKit::Services::Flexray::FlexrayNodeParameters& obj);
void Read(SilKit::Services::Flexray::FlexrayTxBufferConfig& obj);
Expand Down
5 changes: 4 additions & 1 deletion SilKit/source/core/internal/LoggingDatatypesInternal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct LogMsg
{
std::string loggerName;
Level level{Level::Off};
Topic topic{Topic::None};
log_clock::time_point time;
SourceLoc source;
std::string payload;
Expand Down Expand Up @@ -64,7 +65,8 @@ bool operator==(const SourceLoc& lhs, const SourceLoc& rhs)

inline bool operator==(const LogMsg& lhs, const LogMsg& rhs)
{
return lhs.loggerName == rhs.loggerName && lhs.level == rhs.level && lhs.time == rhs.time
return lhs.loggerName == rhs.loggerName && lhs.level == rhs.level && lhs.topic == rhs.topic
&& lhs.time == rhs.time
&& lhs.source == rhs.source && lhs.payload == rhs.payload && lhs.keyValues == rhs.keyValues;
}

Expand Down Expand Up @@ -127,6 +129,7 @@ std::string to_string(const LogMsg& msg)
std::ostream& operator<<(std::ostream& out, const LogMsg& msg)
{
out << "LogMsg{logger=" << msg.loggerName << ", level=" << msg.level
<< ", topic=" << msg.topic
<< ", time=" << std::chrono::duration_cast<std::chrono::microseconds>(msg.time.time_since_epoch()).count()
<< ", source=" << msg.source << ", payload=\"" << msg.payload << "\"" << msg.keyValues << "}";
return out;
Expand Down
32 changes: 32 additions & 0 deletions SilKit/source/core/internal/internal_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,39 @@

#pragma once

namespace VSilKit {
class SystemStateTracker;
class ConnectPeer;
class MetricsProcessor;
} // namespace VSilKit
namespace SilKit {
namespace Dashboard {
class DashboardRestClient;
class DashboardSystemServiceClient;
class DashboardInstance;
} // namespace Dashboard
namespace Experimental {
namespace NetworkSimulation {
class NetworkSimulatorInternal;
class SimulatedNetworkInternal;
class SimulatedNetworkRouter;
} // namespace NetworkSimulation
} // namespace Experimental
namespace Services {
namespace Can {
class CanController;
class IMsgForCanSimulator;
} // namespace Can
namespace Ethernet {
class EthController;
class IMsgForEthSimulator;
} // namespace Ethernet
namespace Flexray {
class FlexrayController;
class IMsgForFlexrayBusSimulator;
} // namespace Flexray
namespace Lin {
class LinController;
class IMsgForLinSimulator;
} // namespace Lin
namespace PubSub {
Expand All @@ -32,15 +53,26 @@ class RpcServerInternal;
class RpcDiscoverer;
} // namespace Rpc
namespace Orchestration {
class TimeConfiguration;
class SystemMonitor;
class LifecycleManagement;
class LifecycleService;
class TimeSyncService;
} // namespace Orchestration
} // namespace Services
namespace Core {
class IParticipantInternal;
class ConnectKnownParticipants;
class RemoteConnectionManager;
class VAsioConnection;
class VAsioRegistry;
template <class SilKitConnectionT>
class Participant;
namespace Discovery {
class IServiceDiscovery;
} // namespace Discovery
namespace RequestReply {
class ParticipantReplies;
class IRequestReplyService;
class IParticipantReplies;
} // namespace RequestReply
Expand Down
Loading