Skip to content

Conversation

@arkjedrz
Copy link
Contributor

@arkjedrz arkjedrz commented Dec 29, 2025

mw_log backend implementation using baselibs.

Closes eclipse-score/score#2424

@github-actions
Copy link

The created documentation from the pull request is available at: docu-html

@arkjedrz arkjedrz requested a review from vinodreddy-g January 5, 2026 09:18
@arkjedrz arkjedrz force-pushed the arkjedrz_mw-log branch 2 times, most recently from 93febff to 8ff01eb Compare January 6, 2026 09:17
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.3.0) and connecting to it...
INFO: Invocation ID: ecaa813e-071f-4614-b09c-b6241402de07
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
DEBUG: Rule 'rust_qnx8_toolchain+' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-eQOopREOYCL5vtTb6c1cwZrql4GVrJ1FqgxarQRe1xs="
DEBUG: Repository rust_qnx8_toolchain+ instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.bazel/external/bazel_tools/tools/build_defs/repo/http.bzl:394:31: in <toplevel>
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'rules_python', the root module requires module version rules_python@1.4.1, but got rules_python@1.5.1 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'bazel_skylib', the root module requires module version bazel_skylib@1.7.1, but got bazel_skylib@1.8.1 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'rules_cc', the root module requires module version rules_cc@0.1.1, but got rules_cc@0.2.8 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'aspect_rules_lint', the root module requires module version aspect_rules_lint@1.0.3, but got aspect_rules_lint@1.10.2 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'buildifier_prebuilt', the root module requires module version buildifier_prebuilt@7.3.1, but got buildifier_prebuilt@8.2.0.2 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'googletest', the root module requires module version googletest@1.17.0.bcr.1, but got googletest@1.17.0.bcr.2 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Loading: 
Loading: 4 packages loaded
Loading: 4 packages loaded
    currently loading: 
WARNING: Target pattern parsing failed.
ERROR: Skipping '//:license-check': no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/logging/logging/BUILD
ERROR: no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/logging/logging/BUILD
INFO: Elapsed time: 24.772s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

@arkjedrz arkjedrz temporarily deployed to workflow-approval January 6, 2026 13:43 — with GitHub Actions Inactive
@arkjedrz arkjedrz marked this pull request as ready for review January 6, 2026 13:53
@arkjedrz arkjedrz temporarily deployed to workflow-approval January 7, 2026 10:09 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval January 7, 2026 13:41 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval January 12, 2026 13:14 — with GitHub Actions Inactive
@arkjedrz arkjedrz self-assigned this Jan 14, 2026
@arkjedrz arkjedrz marked this pull request as draft January 15, 2026 07:28
@arkjedrz arkjedrz temporarily deployed to workflow-approval January 16, 2026 13:25 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval January 19, 2026 08:25 — with GitHub Actions Inactive
@arkjedrz arkjedrz marked this pull request as ready for review January 19, 2026 09:07
@arkjedrz arkjedrz requested a review from rmaddikery January 19, 2026 09:07
@arkjedrz
Copy link
Contributor Author

Source code is ready, renames to be done.

if (logger->IsLogEnabled(current)) {
return current;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@hoppe-and-dreams dont we have some API to just check it instead of manually resolving it ?

Copy link
Contributor

Choose a reason for hiding this comment

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

if let Some(ref path) = self.config_path {
let path_os_str = path.as_os_str();
if !path_os_str.is_empty() {
unsafe { set_var(KEY, path_os_str) };
Copy link
Contributor

Choose a reason for hiding this comment

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

add #safety caluse to all unsafe stuff in this pr

Copy link
Contributor

Choose a reason for hiding this comment

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

What i mean is unsafe inside fn requires // Safety: description why its still safe here


// Verify configuration.
#if defined(x86_64_linux) || defined(arm64_qnx)
static_assert(sizeof(SlotHandle) == 24);

Choose a reason for hiding this comment

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

We need a comment why 24 . Since it is based on the struct size after padding.

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 rephrased a comment and pasted it both to C++ and Rust files.

// Disallow non-ASCII strings.
// ASCII characters are single byte in UTF-8.
if !value.is_ascii() {
panic!("Provided context contains non-ASCII characters: {value}");

Choose a reason for hiding this comment

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

Could we write a comment to replace the panic later. We should avoid panics and asserts in release mode code . I think we need to replace them later with a function which can be panic during development and uses the health monitoring api for release modes.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is low chance that you can do something here, especially complex things. So we shall recheck with cpp but they also call std::terminate in non recoverable errors.

// Get recorder and check it's not null.
// SAFETY: panics on null recorder.
let ptr = unsafe { recorder_get() };
assert!(!ptr.is_null());

Choose a reason for hiding this comment

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

Same for this assert .

/// # Safety
///
/// Method sets `MW_LOG_CONFIG_FILE` environment variable.
/// Setting environment variable is safe only in single-threaded environments.
Copy link
Contributor

Choose a reason for hiding this comment

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

it shall be written that its safe to call it in main, before any other threads start. Otherwise, no one could ever use it. (i know what is written in Rust doc, but this is really what they mean)

if let Some(ref path) = self.config_path {
let path_os_str = path.as_os_str();
if !path_os_str.is_empty() {
unsafe { set_var(KEY, path_os_str) };
Copy link
Contributor

Choose a reason for hiding this comment

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

What i mean is unsafe inside fn requires // Safety: description why its still safe here

// Disallow non-ASCII strings.
// ASCII characters are single byte in UTF-8.
if !value.is_ascii() {
panic!("Provided context contains non-ASCII characters: {value}");
Copy link
Contributor

Choose a reason for hiding this comment

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

There is low chance that you can do something here, especially complex things. So we shall recheck with cpp but they also call std::terminate in non recoverable errors.

#[inline]
fn write_i8(&mut self, v: &i8, spec: &FormatSpec) -> FmtResult {
// SAFETY: FFI calls. Reference is reinterpreted as a pointer of the same type.
unsafe {
Copy link
Contributor

Choose a reason for hiding this comment

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

unsafe shall enclose lowest possible block

#[inline]
fn write_str(&mut self, v: &str, _spec: &FormatSpec) -> FmtResult {
// Get string as pointer and size.
let v_ptr = v.as_ptr() as *const c_char;
Copy link
Contributor

Choose a reason for hiding this comment

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

cast

`mw_log` backend implementation using `baselibs`.
- Improve `Context`:
  - Use it consistenly internally - no allocs.
  - Make use of `From` traits (to and from `&str`).
- Check layout on every logger builder.
  - Cheap and rare operation, no deps to `std::sync` required.
- Improve docs and add safety notes.
- `LogMessage`:
  - Merge `ScoreLoggerWriter` and `LogStream` - less layers.
  - Remove `score_logger_writer.rs`.
  - Add `#[inline]` where applicable.
- Prevent operation in erroneous state (e.g., when null returned).
  - Less branching.
- Move `Send` and `Sync` where actually needed (to `Recorder`).
- Improve example.
@pawelrutkaq pawelrutkaq merged commit a8d7060 into eclipse-score:main Jan 22, 2026
10 checks passed
@arkjedrz arkjedrz deleted the arkjedrz_mw-log branch January 22, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Rust backend that connect frontend to C++ backend

3 participants