+
Skip to content
Open
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
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test --test_output=errors

common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
common --registry=https://bcr.bazel.build

# magic logging configuration
common --@score-baselibs//score/mw/log/detail/flags:KUse_Stub_Implementation_Only=False
common --@score-baselibs//score/mw/log/flags:KRemote_Logging=False

Choose a reason for hiding this comment

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

Why would we want to set this flag "globally" for anyone? Especially as remote logging is the standard way of logging ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understand, currently this is not supported. The code does not compile without it and I copied it from other repos.

ERROR: no such package '@@score-baselibs+//score/mw/log/detail/data_router': BUILD file not found in directory 'score/mw/log/detail/data_router' of external repository @@score-baselibs+. Add a BUILD file to a directory to mark it as a package.
ERROR: /home/pawel/.cache/bazel/_bazel_pawel/d25adba3030c308deb575e8d3085ff8c/external/score-baselibs+/score/mw/log/detail/BUILD:45:11: no such package '@@score-baselibs+//score/mw/log/detail/data_router': BUILD file not found in directory 'score/mw/log/detail/data_router' of external repository @@score-baselibs+. Add a BUILD file to a directory to mark it as a package. and referenced by '@@score-baselibs+//score/mw/log/detail:recorder_config'
ERROR: Analysis of target '//src/mw_log_subscriber:example' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.484s, Critical Path: 0.00s

Maybe I am missing some knowledge here ?

Choose a reason for hiding this comment

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

yeah, your right. I forgot about that. We just have to make sure, this get's changed once we provide the remote backend.

common --@score-baselibs//score/json:base_library=nlohmann
10 changes: 6 additions & 4 deletions BUILD

Choose a reason for hiding this comment

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

The changes in this file seem unrelated to rust log backend. Should be moved to individual PR (or at least individual commit)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they are related, to use new code in other repo You need them. I would not split this into seprate PR because it's direct consequence of adding a code and making it usable to other repos.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@score_cr_checker//:cr_checker.bzl", "copyright_checker")
load("@score_dash_license_checker//:dash.bzl", "dash_license_checker")
load("@score_docs_as_code//:docs.bzl", "docs")
load("@score_tooling//:defs.bzl", "copyright_checker", "dash_license_checker", "setup_starpls", "use_format_targets")
load("@score_format_checker//:macros.bzl", "use_format_targets")
load("@score_starpls_lsp//:starpls.bzl", "setup_starpls")
load("//:project_config.bzl", "PROJECT_CONFIG")

setup_starpls(
Expand All @@ -28,8 +30,8 @@ copyright_checker(
"//:BUILD",
"//:MODULE.bazel",
],
config = "@score_tooling//cr_checker/resources:config",
template = "@score_tooling//cr_checker/resources:templates",
config = "@score_cr_checker//resources:config",
template = "@score_cr_checker//resources:templates",
visibility = ["//visibility:public"],
)

Expand Down
51 changes: 34 additions & 17 deletions MODULE.bazel

Choose a reason for hiding this comment

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

The changes in this file seem unrelated to rust log backend. Should be moved to individual PR (or at least individual commit)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they are related, to use new code in other repo You need them. I would not split this into seprate PR because it's direct consequence of adding a code and making it usable to other repos.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
module(
name = "cpp_rust_template_repository",
version = "1.0",
name = "score-mw-log",
version = "0.1",
)

bazel_dep(name = "rules_python", version = "1.4.1")
Expand All @@ -27,31 +27,48 @@ python.toolchain(
use_repo(python)

# Add GoogleTest dependency
bazel_dep(name = "googletest", version = "1.17.0")
bazel_dep(name = "googletest", version = "1.15.0")

# Rust rules for Bazel
bazel_dep(name = "rules_rust", version = "0.63.0")
bazel_dep(name = "rules_rust", version = "0.56.0")

# Checker rule for CopyRight checks/fixs
bazel_dep(name = "score_cr_checker", version = "0.3.1")
bazel_dep(name = "score_python_basics", version = "0.3.4")
bazel_dep(name = "score_starpls_lsp", version = "0.1.0")

# C/C++ rules for Bazel
bazel_dep(name = "rules_cc", version = "0.2.1")
bazel_dep(name = "rules_cc", version = "0.1.1")

# LLVM Toolchains Rules - host configuration
bazel_dep(name = "toolchains_llvm", version = "1.4.0")
bazel_dep(name = "toolchains_llvm", version = "1.3.0")

# Configure and register the toolchain.
bazel_dep(name = "score_toolchains_gcc", version = "0.4", dev_dependency = True)

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
cxx_standard = {"": "c++17"},
llvm_version = "19.1.0",
gcc = use_extension("@score_toolchains_gcc//extentions:gcc.bzl", "gcc", dev_dependency = True)

Choose a reason for hiding this comment

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

Isn't the toolchain fixed across S-CORE? I was expecting it fixed, as at some point the software has to be build using safety certified compiler.

Choose a reason for hiding this comment

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

Do you mean a fixed version? This declared L47 like described in toolchain repo There is a newer version 0.6 available, but I don't know the version deployment/usage schema in the project.

Choose a reason for hiding this comment

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

Yeah, I mean in the end if an some entity want to put logging into a Vehicle under ISO26262 certification it needs to be compliable/linkable by a certified compiler. Typically those are older versions. Eg. for QNX7 Safety core it was GCC9. Hence a lot of brand new compiler goodies were not allowed to be used.

Here it seems you pull a very recent version, and I'm afraid it will break users who need to compile with the qualified compiler. Do you rely on any such brand new feature?

For the above reason, I thought all S-CORE Repos would have a common GCC = Version X.Y set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We dont rely on any, as You saw, usage is simple usage of baselib code. I think the compiler story, deps alignment and final checking is still not setup up finally in S-CORE. But I think the operational team is working on it. So for now I would skip this discussion here in this PR.

Choose a reason for hiding this comment

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

Yeah, I mean in the end if an some entity want to put logging into a Vehicle under ISO26262 certification it needs to be compliable/linkable by a certified compiler. Typically those are older versions. Eg. for QNX7 Safety core it was GCC9. Hence a lot of brand new compiler goodies were not allowed to be used.

Here it seems you pull a very recent version, and I'm afraid it will break users who need to compile with the qualified compiler. Do you rely on any such brand new feature?

For the above reason, I thought all S-CORE Repos would have a common GCC = Version X.Y set.

So, to my understanding the s-core toolchain repo offers "fixed toolchains" which are versioned. In this PR we make already use of it ( https://github.com/eclipse-score/logging/pull/1/files#diff-6136fc12446089c3db7360e923203dd114b6a1466252e71667c6791c20fe6bdcR47 ).
What we should figure out, is which s-core gcc version shall be used at the moment e.g. 0.4 or the latest 0.6? But to me this is not a blocker, instead can be done later.

Choose a reason for hiding this comment

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

We dont rely on any, as You saw, usage is simple usage of baselib code. I think the compiler story, deps alignment and final checking is still not setup up finally in S-CORE. But I think the operational team is working on it. So for now I would skip this discussion here in this PR.

Okay, then I might just not understand the change being introduced here. To me it looks as if we pull a very recent compiler version in that is out of line with what the rest of the S-core project is using.

If this is not the case and/or it is seen as tech debt with a clear roadmap of when and where to change to. Disregard my comment.

gcc.toolchain(
sha256 = "457f5f20f57528033cb840d708b507050d711ae93e009388847e113b11bf3600",
strip_prefix = "x86_64-unknown-linux-gnu",
url = "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/0.0.1/x86_64-unknown-linux-gnu_gcc12.tar.gz",
)
use_repo(llvm, "llvm_toolchain")
use_repo(llvm, "llvm_toolchain_llvm")
use_repo(gcc, "gcc_toolchain", "gcc_toolchain_gcc")

register_toolchains("@llvm_toolchain//:all")
# Dash license checker
bazel_dep(name = "score_dash_license_checker", version = "0.1.2")

# tooling
bazel_dep(name = "score_tooling", version = "1.0.1")
bazel_dep(name = "aspect_rules_lint", version = "1.5.3")
# Format checker
bazel_dep(name = "score_format_checker", version = "0.1.1")
bazel_dep(name = "aspect_rules_lint", version = "1.4.4")
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")

#docs-as-code
bazel_dep(name = "score_docs_as_code", version = "1.1.0")
bazel_dep(name = "score_docs_as_code", version = "1.0.1")

# Code deps
bazel_dep(name = "score-baselibs", version = "0.1.0")
git_override(
module_name = "score-baselibs",
commit = "ae050e3cc556572830e1ec02ffbcbbd03f26df13", # or use "tag" or "branch"
remote = "https://github.com/eclipse-score/baselibs.git",
)
Empty file added src/cpp/.gitkeep
Empty file.
50 changes: 50 additions & 0 deletions src/rust/mw_log_subscriber/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")

cc_library(
name = "librust_cpp_log_adapter",
srcs = ["src/rust_cpp_log_adapter.cpp"],
visibility = ["//visibility:private"],
deps = [
"@score-baselibs//score/mw/log",
],
)

rust_library(
name = "mw_log_subscriber",
srcs = glob(["src/**/*.rs"]),
crate_name = "mw_log_subscriber",
edition = "2021",
visibility = ["//visibility:public"],
deps = [
":librust_cpp_log_adapter",
"@score-baselibs//score/mw/log/rust:mw_log",
],
)

rust_binary(
name = "example",
srcs = ["examples/main.rs"],
data = [
"examples/config/logging.json",
],
edition = "2021",
visibility = ["//visibility:public"],
deps = [
":mw_log_subscriber",
"@score-baselibs//score/mw/log/rust:mw_log",
],
)
7 changes: 7 additions & 0 deletions src/rust/mw_log_subscriber/examples/config/logging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"appId": "JSON",
"appDesc": "JSON example programs",
"logMode" : "kConsole",
"logLevel": "kVerbose",
"logLevelThresholdConsole": "kInfo"
}
74 changes: 74 additions & 0 deletions src/rust/mw_log_subscriber/examples/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//

Choose a reason for hiding this comment

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

Move this one level up. We can get rid of src dir

Copy link
Contributor Author

@pawelrutkaq pawelrutkaq Oct 14, 2025

Choose a reason for hiding this comment

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

we cannot, this is S-CORE layout. https://github.com/eclipse-score/module_template

Choose a reason for hiding this comment

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

It is src files for the module. Since we will have different modules in the same repo, it does not make sense and we remove it anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do it like that. Please decide. This will be only 4th different way of repo setup in S-CORE repos.

// Copyright (c) 2025 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache License Version 2.0 which is available at
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0
//

use std::path::PathBuf;

use mw_log::{debug, error, info, trace, warn};
use mw_log_subscriber::MwLoggerBuilder;

fn main() {
//Setup for example using config file
let path = PathBuf::from(std::env::current_dir().unwrap())
.join(file!())
.parent()
.unwrap()
.join("config")
.join("logging.json");

std::env::set_var("MW_LOG_CONFIG_FILE", path.as_os_str());

// Just initialize and set as default logger
MwLoggerBuilder::new().set_as_default_logger::<false, true, false>();

trace!("This is a trace log");
debug!("This is a debug log");
error!("This is an error log");
info!("This is an info log");
warn!("This is a warn log");

error!(
"This is an log that will be trimmed: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
END MARKER NOT VISIBLE"
);

error!(
"This is an log that will be trimmed {} {} {} {} {} {} {}. END MARKER NOT VISIBLE",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"
);

// Using logger instance with context
let logger = MwLoggerBuilder::new()
.with_context("ALFA")
.build::<false, true, false>();

trace!(
logger : logger,
"This is a trace log"
);
debug!(logger : logger, "This is a debug log");
error!(logger : logger, "This is an error log");
info!(logger : logger, "This is an info log");
warn!(logger : logger, "This is a warn log");
}
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载