Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 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
aa51412
fixup! Fix review requests
VLukasBecker Apr 22, 2026
1e72c9d
Clean public and internal logger usage
VLukasBecker Apr 23, 2026
185a41c
Merge branch 'main' into dev_logger_topics
VLukasBecker Apr 24, 2026
ee6dca4
Fix review requests
VLukasBecker Apr 27, 2026
e440904
fixup! Fix review requests
VLukasBecker Apr 27, 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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enable_testing()
if(MSVC)
#make sure Release is built with debug PDBs
add_compile_options(/Zi )
add_compile_options(/utf-8)
endif()

if(SILKIT_ENABLE_TRACING_INSTRUMENTATION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void SetCurrentWorkingDir(const std::string& cwd)
class StdoutLogger : public SilKit::Core::Tests::MockLogger
{
public:
void Info(const std::string& msg) override
/* void Info(const std::string& msg) override
{
std::cout << "SilKitExtensionTest: Info: " << msg << std::endl;
}
Expand All @@ -55,7 +55,7 @@ class StdoutLogger : public SilKit::Core::Tests::MockLogger
void Error(const std::string& msg) override
{
std::cout << "SilKitExtensionTest: Error: " << msg << std::endl;
}
}*/
};
} // namespace

Expand Down
10 changes: 10 additions & 0 deletions SilKit/source/CreateParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ auto CreateParticipantImpl(std::shared_ptr<SilKit::Config::IParticipantConfigura
return CreateParticipantImpl(participantConfig, participantName, uri);
}

auto GetLoggerInternal(SilKit::IParticipant* participant) -> SilKit::Services::Logging::ILoggerInternal*
{
auto participantImpl = dynamic_cast<Core::IParticipantInternal*>(participant);
if (participantImpl == nullptr)
{
throw SilKit::ConfigurationError("The provided participant is not a valid SilKit::Core::IParticipantInternal");
}
return participantImpl->GetLoggerInternal();
}

} //namespace SilKit
9 changes: 9 additions & 0 deletions SilKit/source/CreateParticipantImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class IParticipantConfiguration;
} // namespace Config
} // namespace SilKit

namespace SilKit {
namespace Services {
namespace Logging {
struct ILoggerInternal; // todo check or remove, move to own file
} // namespace Logging
} // namespace Services
} // namespace SilKit

// Function Declarations

Expand All @@ -34,4 +41,6 @@ auto CreateParticipantImpl(std::shared_ptr<SilKit::Config::IParticipantConfigura
auto CreateParticipantImpl(std::shared_ptr<SilKit::Config::IParticipantConfiguration> participantConfig,
const std::string& participantName) -> std::unique_ptr<IParticipant>;

auto GetLoggerInternal(SilKit::IParticipant* participant ) -> SilKit::Services::Logging::ILoggerInternal*;// todo check or remove, move to own file
} // namespace SilKit

10 changes: 10 additions & 0 deletions SilKit/source/CreateSilKitRegistryImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ auto CreateSilKitRegistryImpl(std::shared_ptr<SilKit::Config::IParticipantConfig
return std::make_unique<Core::VAsioRegistry>(config);
}

auto GetLoggerInternal(ISilKitRegistry* participant) -> SilKit::Services::Logging::ILoggerInternal*
{
auto participantImpl = dynamic_cast<Core::VAsioRegistry*>(participant);
if (participantImpl == nullptr)
{
throw SilKit::ConfigurationError("The provided participant is not a valid SilKit::Core::IParticipantInternal");
}
return participantImpl->GetLoggerInternal();
}

} // namespace Vector
} // namespace Vendor
} // namespace SilKit
10 changes: 10 additions & 0 deletions SilKit/source/CreateSilKitRegistryImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@

// Forward Declarations

namespace SilKit {
namespace Services {
namespace Logging {
struct ILoggerInternal; // todo check or remove, move to own file
} // namespace Logging
} // namespace Services
} // namespace SilKit

namespace SilKit {
namespace Config {
class IParticipantConfiguration;
Expand All @@ -39,6 +47,8 @@ namespace Vector {
auto CreateSilKitRegistryImpl(std::shared_ptr<SilKit::Config::IParticipantConfiguration> config)
-> std::unique_ptr<ISilKitRegistry>;

auto GetLoggerInternal(ISilKitRegistry* participant)
-> SilKit::Services::Logging::ILoggerInternal*; // todo check or remove, move to own file
} // namespace Vector
} // namespace Vendor
} // namespace SilKit
15 changes: 11 additions & 4 deletions SilKit/source/capi/CapiLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

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

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

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

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

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);

logger->MakeMessage(enumLevel, SilKit::Services::Logging::Topic::User)
.SetMessage(useString)
.Dispatch();


return SilKit_ReturnCode_SUCCESS;
}
CAPI_CATCH_EXCEPTIONS
Expand Down
2 changes: 1 addition & 1 deletion SilKit/source/capi/CapiParticipant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ try
ASSERT_VALID_POINTER_PARAMETER(participant);

auto cppParticipant = reinterpret_cast<SilKit::IParticipant*>(participant);
auto logger = cppParticipant->GetLogger();
auto logger = GetLoggerInternal(cppParticipant);
*outLogger = reinterpret_cast<SilKit_Logger*>(logger);
return SilKit_ReturnCode_SUCCESS;
}
Expand Down
8 changes: 8 additions & 0 deletions SilKit/source/capi/Test_CapiLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "gmock/gmock.h"
#include "silkit/capi/SilKit.h"
#include "silkit/services/logging/all.hpp"
#include "LoggingTopics.hpp"

namespace {
using namespace SilKit::Services::Logging;
Expand All @@ -14,12 +15,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
4 changes: 4 additions & 0 deletions SilKit/source/config/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

#include "silkit/participant/exception.hpp"
#include "silkit/SilKitMacros.hpp"

#include "silkit/services/logging/LoggingDatatypes.hpp"
#include "LoggingTopics.hpp"

#include "StringHelpers.hpp"

Expand Down Expand Up @@ -81,6 +83,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: 23 additions & 1 deletion SilKit/source/config/YamlReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: MIT
#include "YamlReader.hpp"
#include "silkit/services/logging/string_utils.hpp"
#include "string_utils_internal.hpp"

namespace VSilKit {

Expand All @@ -24,7 +26,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 +48,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 +215,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 @@ -277,6 +277,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
7 changes: 5 additions & 2 deletions SilKit/source/core/internal/LoggingDatatypesInternal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "silkit/services/logging/LoggingDatatypes.hpp"
#include "silkit/services/logging/string_utils.hpp"
#include "string_utils_internal.hpp"

namespace SilKit {
namespace Services {
Expand All @@ -34,6 +35,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 All @@ -49,7 +51,6 @@ inline std::ostream& operator<<(std::ostream& out, const SourceLoc& sourceLoc);
inline std::string to_string(const LogMsg& msg);
inline std::ostream& operator<<(std::ostream& out, const LogMsg& msg);


inline std::string to_string(const std::vector<std::pair<std::string, std::string>>& kv);
inline std::ostream& operator<<(std::ostream& out, const std::vector<std::pair<std::string, std::string>>& kv);

Expand All @@ -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
45 changes: 45 additions & 0 deletions SilKit/source/core/internal/LoggingTopics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-FileCopyrightText: 2022 Vector Informatik GmbH
//
// SPDX-License-Identifier: MIT

#pragma once

#include <cstdint>

namespace SilKit {
namespace Services {
namespace Logging {

/*! \brief Topic of a log message
*/
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,
Can = 12,
Ethernet = 13,
Flexray = 14,
Lin = 15,
Metrics = 16,
Pubsub = 17,
Rpc = 18,
Tracing = 19,
Dashboard = 20,
NetSim = 21,
Extension = 22,
Invalid = 0xffffffff //!< Invalid log message topic
};

} // namespace Logging
} // namespace Services
} // namespace SilKit
10 changes: 6 additions & 4 deletions SilKit/source/core/internal/MessageBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ MessageBuffer& MessageBuffer::operator<<(const std::string& str)
_storage.resize(_wPos + str.size());
}

std::copy(str.begin(), str.end(), _storage.begin() + _wPos);
std::copy(str.begin(), str.end(), _storage.begin() + static_cast<decltype(_storage)::difference_type>(_wPos));
_wPos += str.size();

return *this;
Expand All @@ -311,7 +311,7 @@ MessageBuffer& MessageBuffer::operator>>(std::string& str)
if (_rPos + strLength > _storage.size())
throw end_of_buffer{};

str = std::string(_storage.begin() + _rPos, _storage.begin() + _rPos + strLength);
str = std::string(_storage.begin() + static_cast<decltype(_storage)::difference_type>(_rPos), _storage.begin() + static_cast<decltype(_storage)::difference_type>(_rPos + strLength));
_rPos += strLength;

return *this;
Expand All @@ -332,7 +332,9 @@ MessageBuffer& MessageBuffer::operator>>(std::vector<uint8_t>& vector)
if (_rPos + vectorSize > _storage.size())
throw end_of_buffer{};

vector = std::vector<uint8_t>(_storage.begin() + _rPos, _storage.begin() + _rPos + vectorSize);
vector =
std::vector<uint8_t>(_storage.begin() + static_cast<decltype(_storage)::difference_type>(_rPos),
_storage.begin() + static_cast<decltype(_storage)::difference_type>(_rPos + vectorSize));
_rPos += vectorSize;

return *this;
Expand Down Expand Up @@ -399,7 +401,7 @@ inline MessageBuffer& MessageBuffer::operator<<(const Util::Span<const uint8_t>&
_storage.resize(_wPos + span.size());
}

std::copy(span.begin(), span.end(), _storage.begin() + _wPos);
std::copy(span.begin(), span.end(), _storage.begin() + static_cast<decltype(_storage)::difference_type>(_wPos));
_wPos += span.size();
return *this;
}
Expand Down
Loading
Loading