diff --git a/bazel_common/score_modules_target_sw.MODULE.bazel b/bazel_common/score_modules_target_sw.MODULE.bazel index 86ba1857320..bbd72e3e618 100644 --- a/bazel_common/score_modules_target_sw.MODULE.bazel +++ b/bazel_common/score_modules_target_sw.MODULE.bazel @@ -74,8 +74,10 @@ git_override( commit = "6282f3a2ec6b1eeeab87c8e9a4435c586bcf9973", patch_strip = 1, patches = [ + "//patches/logging:001-logging-example-visibility.patch", "//patches/logging:002-needs-json-deps-not-dev-dependency.patch", "//patches/logging:003-docs-as-code-not-dev-dependency.patch", + "//patches/logging:004-rules-pkg-not-dev-dependency.patch", ], remote = "https://github.com/eclipse-score/logging.git", ) diff --git a/feature_integration_tests/itf/test_remote_logging.py b/feature_integration_tests/itf/test_remote_logging.py index 58101d41ab4..353fce37038 100644 --- a/feature_integration_tests/itf/test_remote_logging.py +++ b/feature_integration_tests/itf/test_remote_logging.py @@ -111,3 +111,46 @@ def test_remote_logging(datarouter_running, dlt_config): assert message_count > 1, ( f"Expected atleast one DLT message with app_id: {APP_ID} and context_id: {CTX_ID}, but got {message_count}" ) + + +# DLT message identifiers for the Logging App +LOGGING_APP_ID = "EXA" +LOGGING_CTX_ID = "DFLT" + +_LOGGINGAPP_START_CMD = "cd /showcases/data/logging/logging_app/etc && nohup /showcases/bin/logging_app &" + + +def test_logging_app_logs_forwarded_to_dlt(datarouter_running, target, dlt_config): + """Verifies that Logging App logs are forwarded to DLT.""" + + with DltWindow( + protocol=Protocol.UDP, + host_ip=dlt_config.host_ip, + multicast_ips=dlt_config.multicast_ips, + print_to_stdout=True, + binary_path=dlt_config.dlt_receive_path, + ) as window: + logger.info("Starting logging_app...") + exit_code, out = target.execute(_LOGGINGAPP_START_CMD) + + logger.info("logging_app start exit_code=%s", exit_code) + logger.info(out.decode(errors="replace")) + + assert exit_code == 0, "Failed to start logging_app" + + time.sleep(CAPTURE_DURATION_SECONDS) + + record = window.record(filters=[(LOGGING_APP_ID, LOGGING_CTX_ID)]) + messages = record.find(query=dict(apid=LOGGING_APP_ID, ctid=LOGGING_CTX_ID)) + + logger.debug( + "Found %d messages with app_id=%s, context_id=%s", + len(messages), + LOGGING_APP_ID, + LOGGING_CTX_ID, + ) + + assert len(messages) > 0, ( + f"Expected at least one DLT message with app_id={LOGGING_APP_ID} " + f"and context_id={LOGGING_CTX_ID}, but got {len(messages)}" + ) diff --git a/known_good.json b/known_good.json index 708b6bfdcbd..b3feb9637f0 100644 --- a/known_good.json +++ b/known_good.json @@ -99,8 +99,10 @@ "repo": "https://github.com/eclipse-score/logging.git", "hash": "6282f3a2ec6b1eeeab87c8e9a4435c586bcf9973", "bazel_patches": [ + "//patches/logging:001-logging-example-visibility.patch", "//patches/logging:002-needs-json-deps-not-dev-dependency.patch", - "//patches/logging:003-docs-as-code-not-dev-dependency.patch" + "//patches/logging:003-docs-as-code-not-dev-dependency.patch", + "//patches/logging:004-rules-pkg-not-dev-dependency.patch" ], "metadata": { diff --git a/patches/logging/001-logging-example-visibility.patch b/patches/logging/001-logging-example-visibility.patch new file mode 100644 index 00000000000..fc4650310fb --- /dev/null +++ b/patches/logging/001-logging-example-visibility.patch @@ -0,0 +1,38 @@ +diff --git a/score/test/component/dlt_generator_app/BUILD b/score/test/component/dlt_generator_app/BUILD +index 9736cac..a60ebd6 100644 +--- a/score/test/component/dlt_generator_app/BUILD ++++ b/score/test/component/dlt_generator_app/BUILD +@@ -29,9 +29,14 @@ load("@rules_pkg//pkg:tar.bzl", "pkg_tar") + cc_binary( + name = "dlt_generator", + srcs = ["dlt_generator.cpp"], ++ visibility = ["//visibility:public"], + deps = ["//score/mw/log"], + ) + ++exports_files([ ++ "etc/logging.json", ++]) ++ + pkg_tar( + name = "dlt_generator_bin_pkg", + srcs = [":dlt_generator"], +diff --git a/score/test/component/logging_app/BUILD b/score/test/component/logging_app/BUILD +index de63c65..f9f3346 100644 +--- a/score/test/component/logging_app/BUILD ++++ b/score/test/component/logging_app/BUILD +@@ -29,9 +29,14 @@ load("@rules_pkg//pkg:tar.bzl", "pkg_tar") + cc_binary( + name = "logging_app", + srcs = ["logging_app.cpp"], ++ visibility = ["//visibility:public"], + deps = ["//score/mw/log"], + ) + ++exports_files([ ++ "etc/logging.json", ++]) ++ + pkg_tar( + name = "logging_app_bin_pkg", + srcs = [":logging_app"], diff --git a/patches/logging/004-rules-pkg-not-dev-dependency.patch b/patches/logging/004-rules-pkg-not-dev-dependency.patch new file mode 100644 index 00000000000..c3336a45923 --- /dev/null +++ b/patches/logging/004-rules-pkg-not-dev-dependency.patch @@ -0,0 +1,13 @@ +diff --git a/MODULE.bazel b/MODULE.bazel +index 5eed2f9..06fb222 100644 +--- a/MODULE.bazel ++++ b/MODULE.bazel +@@ -47,7 +47,7 @@ bazel_dep(name = "score_itf", version = "0.4.0", dev_dependency = True) + + # OCI / Docker image rules for integration tests + bazel_dep(name = "rules_oci", version = "2.2.7", dev_dependency = True) +-bazel_dep(name = "rules_pkg", version = "1.2.0", dev_dependency = True) ++bazel_dep(name = "rules_pkg", version = "1.2.0") + + # QNX image filesystem rules for QNX integration tests + bazel_dep(name = "score_rules_imagefs", version = "0.0.1", dev_dependency = True) diff --git a/showcases/BUILD b/showcases/BUILD index e8e8c0649ca..84f6f32440a 100644 --- a/showcases/BUILD +++ b/showcases/BUILD @@ -19,6 +19,7 @@ score_pkg_bundle( "//showcases/standalone:comm_pkg_files", "//showcases/standalone:kyron_pkg_files", "//showcases/standalone:time_pkg_files", + "//showcases/standalone:logging_pkg_files", "//showcases/orchestration_persistency:orch_per_pkg_files", "//showcases/simple_lifecycle:simple_lifecycle_pkg_files", ], diff --git a/showcases/README.md b/showcases/README.md new file mode 100644 index 00000000000..53b69c55171 --- /dev/null +++ b/showcases/README.md @@ -0,0 +1,7 @@ +# Logging App Demo + +This Logging App demonstrates logging using mw::log with all log levels and configured backends (kConsole|kRemote|kFile) enabled. + +For remote (DLT) logging, please refer to the following documentation: + +[Remote logging](https://github.com/eclipse-score/logging/blob/main/score/datarouter/doc/guideline/dlt_capture_demo.md) \ No newline at end of file diff --git a/showcases/standalone/BUILD b/showcases/standalone/BUILD index 3b2f544d9d1..e6bc7d19a9b 100644 --- a/showcases/standalone/BUILD +++ b/showcases/standalone/BUILD @@ -50,3 +50,19 @@ score_pkg_bundle( ], package_dir = "standalone", ) + +score_pkg_bundle( + name = "logging", + bins = [ + "@score_logging//score/test/component/logging_app:logging_app", + "@score_logging//score/test/component/dlt_generator_app:dlt_generator", + ], + config_data = [ + "//showcases/standalone:logging.score.json", + ], + custom_layout = { + "@score_logging//score/test/component/logging_app:etc/logging.json": "logging_app/etc/logging.json", + "@score_logging//score/test/component/dlt_generator_app:etc/logging.json": "dlt_generator/etc/logging.json", + }, + package_dir = "standalone", +) diff --git a/showcases/standalone/logging.score.json b/showcases/standalone/logging.score.json new file mode 100644 index 00000000000..9982d6c1d84 --- /dev/null +++ b/showcases/standalone/logging.score.json @@ -0,0 +1,27 @@ +{ + "name": "LoggingApp Demo", + "description": "A Logging app that demonstrates logging with mw::log with kConsole|kRemote|kFile config.", + "apps": [ + { + "path": "/bin/sh", + "args": [ + "-c", + "cd /usr/bin/datarouter && ./datarouter --no_adaptive_runtime >/dev/null 2>&1 &" + ], + "env": {} + }, + { + "path": "/showcases/bin/logging_app", + "args": [], + "env": {}, + "dir": "/showcases/data/logging/logging_app/etc" + }, + + { + "path": "/showcases/bin/dlt_generator", + "args": [], + "env": {}, + "dir": "/showcases/data/logging/dlt_generator/etc" + } + ] + }