Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ build:_common --features=minimal_warnings --features=-strict_warnings --features
common --@score_baselibs//score/memory/shared/flags:use_typedshmd=False
common --@score_baselibs//score/mw/log/flags:KRemote_Logging=False
common --@score_baselibs//score/json:base_library=nlohmann
common --//score/datarouter/build_configuration_flags:persistent_logging=False
common --//score/datarouter/build_configuration_flags:persistent_config_feature_enabled=False
common --//score/datarouter/build_configuration_flags:enable_dynamic_configuration=False
common --//score/datarouter/build_configuration_flags:file_transfer=False
Expand Down
40 changes: 3 additions & 37 deletions score/datarouter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ cc_library(
visibility = [
"//score/datarouter/dlt_filetransfer_trigger_lib:__pkg__",
"//score/datarouter/src/file_transfer:__subpackages__",
"//score/datarouter/src/persistent_logging/persistent_logging:__pkg__",
"//score/datarouter/test:__subpackages__",
],
deps = [
Expand Down Expand Up @@ -178,8 +177,6 @@ cc_library(
"//score/datarouter/src/dlt/nonverbose_dlt_impl:__pkg__",
"//score/datarouter/src/dlt/nonverbose_dlt_stub:__pkg__",
"//score/datarouter/src/file_transfer:__subpackages__",
"//score/datarouter/src/persistent_logging:__pkg__",
"//score/datarouter/src/persistent_logging/persistent_logging:__pkg__",
"//score/datarouter/test:__subpackages__",
],
deps = [
Expand All @@ -201,8 +198,6 @@ cc_library(
"//score/datarouter/src/dlt/nonverbose_dlt_impl:__pkg__",
"//score/datarouter/src/dlt/nonverbose_dlt_stub:__pkg__",
"//score/datarouter/src/file_transfer:__subpackages__",
"//score/datarouter/src/persistent_logging:__pkg__",
"//score/datarouter/src/persistent_logging/persistent_logging:__pkg__",
],
deps = [
":datarouter_types",
Expand Down Expand Up @@ -384,6 +379,7 @@ cc_library(
visibility = ["//score/datarouter/test:__subpackages__"],
deps = [
"//score/mw/log",
"@score_baselibs//score/os:getopt",
],
)

Expand Down Expand Up @@ -527,9 +523,6 @@ cc_library(
}) + select({
"//score/datarouter/build_configuration_flags:config_file_transfer": ["DLT_FILE_TRANSFER_FEATURE"],
"//conditions:default": [],
}) + select({
"//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"],
"//conditions:default": [],
}),
strip_include_prefix = "include",
visibility = [
Expand Down Expand Up @@ -561,13 +554,6 @@ cc_library(
"//conditions:default": [
dc_stub_dep,
],
}) + select({
"//score/datarouter/build_configuration_flags:config_persistent_logging": [
"//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub",
],
"//conditions:default": [
"//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub",
],
}),
)
for name, ara_fact_dep, nv_dep, nv_stub_dep, dc_dep, dc_stub_dep, ft_dep, test_only in [
Expand Down Expand Up @@ -626,7 +612,6 @@ cc_library(
":udp_stream_output",
":unixdomain_server",
"//score/datarouter/network:vlan",
"//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub",
"//score/mw/log",
"@score_baselibs//score/language/futurecpp",
"@score_baselibs//score/mw/log/configuration:nvconfig",
Expand Down Expand Up @@ -790,10 +775,6 @@ cc_library(
"//conditions:default": [],
}),
features = COMPILER_WARNING_FEATURES,
local_defines = select({
"//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"],
"//conditions:default": [],
}),
strip_include_prefix = "include",
visibility = [
"//score/datarouter/test:__subpackages__",
Expand All @@ -806,12 +787,7 @@ cc_library(
":persistentlogconfig",
":socketserver_config_lib",
"@score_baselibs//score/mw/log/configuration:nvconfigfactory",
] + select({
"//score/datarouter/build_configuration_flags:config_persistent_logging": [
"//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub",
],
"//conditions:default": [],
}),
],
)

cc_library(
Expand All @@ -830,10 +806,6 @@ cc_library(
"//conditions:default": [],
}),
features = COMPILER_WARNING_FEATURES,
local_defines = select({
"//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"],
"//conditions:default": [],
}),
strip_include_prefix = "include",
visibility = ["//score/datarouter/test:__subpackages__"],
deps = [
Expand All @@ -843,12 +815,7 @@ cc_library(
":persistentlogconfig",
":socketserver_config_lib_testing",
"@score_baselibs//score/mw/log/configuration:nvconfigfactory",
] + select({
"//score/datarouter/build_configuration_flags:config_persistent_logging": [
"//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub",
],
"//conditions:default": [],
}),
],
)

[
Expand Down Expand Up @@ -1106,7 +1073,6 @@ cc_library(
"//score/mw/log",
"@score_baselibs//score/mw/log/configuration:nvconfig",
"//score/datarouter/dlt_filetransfer_trigger_lib:filetransfer_message_types",
"//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub",
],
)

Expand Down
16 changes: 0 additions & 16 deletions score/datarouter/build_configuration_flags/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

bool_flag(
name = "persistent_logging",
build_setting_default = False,
)

config_setting(
name = "config_persistent_logging",
flag_values = {
":persistent_logging": "True",
},
visibility = [
"//platform/aas/log_and_trace/datarouterconf:__subpackages__",
"@score_logging//score/datarouter:__subpackages__",
],
)

bool_flag(
name = "persistent_config_feature_enabled",
build_setting_default = True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
namespace score::logging
{

MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, score::platform::DltidT)
SCORE_MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, score::platform::DltidT)
// Suppress "AUTOSAR C++14 A18-9-4". The rule states: An argument to std::forward shall not be subsequently used.
// Rationale: STRUCT_TRACEABLE is a macro, std::forward is from the macro definition
// Rationale: SCORE_STRUCT_TRACEABLE is a macro, std::forward is from the macro definition
// Suppress "AUTOSAR C++14 M3-2-3". The rule states: "A type, object or function that is used in
// multiple translation units shall be declared in one and only one file.".
// Rationale: This is a forward declaration that does not vioalate this rule.
// coverity[autosar_cpp14_a18_9_4_violation]
// coverity[autosar_cpp14_m3_2_3_violation]
STRUCT_TRACEABLE(FileTransferEntry, appid, ctxid, file_name, delete_file)
SCORE_STRUCT_TRACEABLE(FileTransferEntry, appid, ctxid, file_name, delete_file)

} // namespace score::logging

Expand Down
2 changes: 1 addition & 1 deletion score/datarouter/doc/design/logging_architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The Serialization/Visitor pattern implements structure serialization using C++ c
1. The compile-time macro:

```c++
STRUCT_TRACEABLE(S, member1, member2)
SCORE_STRUCT_TRACEABLE(S, member1, member2)
```

generates a `visit(Visitor& v, T& s)` function template that iterates through arguments and their names (`S, "member1", member1, "member2", member2`) with a compile-time `Visitor`. The visitor type serves as a function template argument, enabling `visit(v,s)` usage with different visitor implementations. Each visitor defines a `visit_struct()` entry point function.
Expand Down
18 changes: 18 additions & 0 deletions score/datarouter/doc/guideline/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,21 @@ The file has multiple sections.
- **messageThresholds**: specifies filter thresholds based on AppId and CtxId
- **defaultChannel**: if no channelAssignment has been matched, this channel is used
- **defaultThresold**: if no messageThreshold matched, this threshold is used to filter the messages

### Overriding the config file path at runtime

By default the datarouter reads `log-channels.json` from `./etc/log-channels.json` relative to its working directory. The path can be overridden at startup using the `-c` / `--config` flag:

```bash
./datarouter --no_adaptive_runtime --config /path/to/log-channels.json
```

This is useful for image-level configuration (different deployment images can supply different channel layouts without recompilation) or for manual testing against a local config file without modifying the installed `etc/` tree.

Similarly, the non-verbose configuration file (`class-id.json`) uses a compiled-in deployment path when no override is given, and can be overridden with `-C` / `--nv-config`:

```bash
./datarouter --no_adaptive_runtime --nv-config /path/to/class-id.json
```

When neither flag is provided the datarouter uses its compiled-in default paths: `./etc/log-channels.json` for the channel configuration and a fixed deployment path for the non-verbose configuration.
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,12 @@
#include "score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_stream_handler_stub.h"
#endif

#if defined(PERSISTENT_LOGGING)
#include "score/datarouter/src/persistent_logging/persistent_logging/sysedr_concrete_factory.h"
#else
#include "score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_factory.h"
#endif

namespace score
{
namespace platform
{
namespace internal
{

#if defined(PERSISTENT_LOGGING)
using SysedrHandlerType = SysedrHandler;
using SysedrFactoryType = SysedrConcreteFactory;
#else
using SysedrHandlerType = StubSysedrHandler;
using SysedrFactoryType = StubSysedrFactory;
#endif

} // namespace internal

namespace datarouter
Expand Down
11 changes: 2 additions & 9 deletions score/datarouter/include/daemon/dlt_log_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace dltserver
{

const std::string kLogEntryTypeName{"score::mw::log::detail::LogEntry"};
const std::string kPersistentRequestTypeName{"score::logging::internal::PersistentLoggingRequestStructure"};
const std::string kFileTransferTypeName{"score::logging::FileTransferEntry"};
class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOutput,
DltVerboseHandler::IOutput,
Expand Down Expand Up @@ -93,23 +92,19 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut
parser_(parser ? std::move(parser) : std::make_unique<DiagnosticJobParser>())
{
InitLogChannels();
SysedrFactoryType sysedr_factory;
sysedr_handler_ = sysedr_factory.CreateSysedrHandler();
}

virtual ~DltLogServer() = default;
// Not possible to mock LogParser currently.
// LCOV_EXCL_START
std::vector<ILogParser::AnyHandler*> GetGlobalHandlers()
{
return {sysedr_handler_.get(), &nvhandler_};
return {&nvhandler_};
}

std::vector<ILogParser::TypeHandlerBinding> GetTypeHandlerBindings()
{
return {{kPersistentRequestTypeName, sysedr_handler_.get()},
{kLogEntryTypeName, &vhandler_},
{kFileTransferTypeName, &fthandler_}};
return {{kLogEntryTypeName, &vhandler_}, {kFileTransferTypeName, &fthandler_}};
}

// LCOV_EXCL_STOP
Expand Down Expand Up @@ -313,8 +308,6 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut
std::unique_ptr<ILogSender> log_sender_;
std::unique_ptr<IDiagnosticJobParser> parser_;

std::unique_ptr<ISysedrHandler> sysedr_handler_;

void SendNonVerbose(const score::mw::log::config::NvMsgDescriptor& desc,
uint32_t tmsp,
const void* data,
Expand Down
19 changes: 15 additions & 4 deletions score/datarouter/include/daemon/socketserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <functional>
#include <iostream>
#include <memory>
#include <optional>
#include <string>

// Forward declaration for testing
Expand Down Expand Up @@ -68,10 +69,16 @@ class SocketServer
bool is_dlt_enabled{false};
};

static void Run(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime)
// A std::nullopt log_channels_path / nv_config_path keeps the built-in
// default path, so the default behaviour is preserved unless --config /
// --nv-config were provided.
static void Run(const std::atomic_bool& exit_requested,
const bool no_adaptive_runtime,
const std::optional<std::string>& log_channels_path = std::nullopt,
const std::optional<std::string>& nv_config_path = std::nullopt)
{
static SocketServer server;
server.DoWork(exit_requested, no_adaptive_runtime);
server.DoWork(exit_requested, no_adaptive_runtime, log_channels_path, nv_config_path);
}
// static void run(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime);

Expand All @@ -81,7 +88,8 @@ class SocketServer
std::unique_ptr<IPersistentDictionary>& persistent_dictionary);

static std::unique_ptr<score::logging::dltserver::DltLogServer> CreateDltServer(
const PersistentStorageHandlers& storage_handlers);
const PersistentStorageHandlers& storage_handlers,
const std::optional<std::string>& log_channels_path = std::nullopt);

static std::unique_ptr<score::platform::internal::ILogParserFactory> CreateLogParserFactory(
score::logging::dltserver::DltLogServer& dlt_server);
Expand Down Expand Up @@ -120,7 +128,10 @@ class SocketServer
const std::string& appid);

private:
void DoWork(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime);
void DoWork(const std::atomic_bool& exit_requested,
const bool no_adaptive_runtime,
const std::optional<std::string>& log_channels_path,
const std::optional<std::string>& nv_config_path);
};

} // namespace datarouter
Expand Down
12 changes: 6 additions & 6 deletions score/datarouter/include/dlt/logentry_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ namespace score
namespace platform
{

// The MEMCPY_SERIALIZABLE macro is part of the Tracing infrastructure and is tested independently.
// The SCORE_MEMCPY_SERIALIZABLE macro is part of the Tracing infrastructure and is tested independently.
// This usage is declarative only and does not contain logic specific to this module.
// Excluding from coverage to avoid inflating coverage metrics with non-functional declarations.
// LCOV_EXCL_START : See above
// MEMCPY_SERIALIZABLE won't cause data loss.
// SCORE_MEMCPY_SERIALIZABLE won't cause data loss.
// coverity[autosar_cpp14_a4_7_1_violation]
MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, DltidT)
SCORE_MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, DltidT)
// LCOV_EXCL_STOP

namespace internal
Expand All @@ -48,17 +48,17 @@ struct LogEntryFilter
uint8_t log_level_threshold = 0U;
};

// The STRUCT_TRACEABLE macro is part of the Tracing infrastructure and is tested independently.
// The SCORE_STRUCT_TRACEABLE macro is part of the Tracing infrastructure and is tested independently.
// This usage is declarative only and does not contain logic specific to this module.
// Excluding from coverage to avoid inflating coverage metrics with non-functional declarations.
// LCOV_EXCL_START : See above
// Suppress "AUTOSAR C++14 A18-9-4". The rule states: An argument to std::forward shall not be subsequently used.
// Rationale: STRUCT_TRACEABLE is a macro, std::forward is from the macro definition
// Rationale: SCORE_STRUCT_TRACEABLE is a macro, std::forward is from the macro definition
// Suppress "AUTOSAR C++14 M3-2-3" rule finding. This rule states: "A type, object or function that is used in multiple
// translation units shall be declared in one and only one file.".
// coverity[autosar_cpp14_a18_9_4_violation]
// coverity[autosar_cpp14_m3_2_3_violation]
STRUCT_TRACEABLE(LogEntryFilter, app_id, ctx_id, log_level_threshold)
SCORE_STRUCT_TRACEABLE(LogEntryFilter, app_id, ctx_id, log_level_threshold)
// LCOV_EXCL_STOP

} // namespace internal
Expand Down
2 changes: 1 addition & 1 deletion score/datarouter/src/applications/datarouter_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void DatarouterAppRun(const std::atomic_bool& exit_requested)

score::mw::log::LogInfo() << "datarouter successfully completed initialization and goes live!";

SocketServer::Run(exit_requested, opts.NoAdaptiveRuntime());
SocketServer::Run(exit_requested, opts.NoAdaptiveRuntime(), opts.ConfigPath(), opts.NvConfigPath());
}

void DatarouterAppShutdown()
Expand Down
Loading
Loading