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: 8cc46ddc-7f90-462f-9447-7685a2c0e754
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: 
WARNING: For repository 'rules_python', the root module requires module version [email protected], but got [email protected] 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 [email protected], but got [email protected] 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 [email protected], but got [email protected] 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 [email protected], but got [email protected] 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 [email protected], but got [email protected] 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 [email protected], but got [email protected] 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: 13.033s
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.


trace!("This is a trace log - hidden");
debug!("This is a debug log - hidden");
error!("This is an error log");
Copy link
Contributor

Choose a reason for hiding this comment

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

missing usage with constext on default logger

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.

// Copy data into array.
let mut data: [c_char; 4] = [0; 4];
unsafe {
core::ptr::copy_nonoverlapping(context.as_ptr(), data.as_mut_ptr() as *mut u8, size);
Copy link
Contributor

Choose a reason for hiding this comment

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

cast<>() instead as


impl Recorder {
pub fn new() -> Self {
let inner = unsafe { recorder_get() };
Copy link
Contributor

Choose a reason for hiding this comment

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

caling C FFi shall do ptr checking. So check nullptrs ie with debug_assert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do, but why debug_assert and not assert?

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

// Create log stream.
let context = metadata.context();
let log_level = metadata.level().into();
let log_stream = LogStream::new(&self.recorder, context, log_level);
Copy link
Contributor

Choose a reason for hiding this comment

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

as writen before, if internals of this failed, we can jsut skip logging here.

}

// SAFETY: The underlying C++ logger is known to be thread-safe.
unsafe impl Send for ScoreLogger {}
Copy link
Contributor

Choose a reason for hiding this comment

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

The C++ ffi types shall have sync/send markups

/// [`score_log::fmt::ScoreWrite`] writer implementation used by [`crate::ScoreLogger`].
/// Adds values to the log stream with selected formatting.
pub(crate) struct ScoreLoggerWriter<'a> {
log_stream: LogStream<'a>,
Copy link
Contributor

Choose a reason for hiding this comment

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

btw why not implement ScoreWrite over LogStream and doing next class here ?

Self { recorder, slot }
}

pub fn log_bool(&mut self, v: &bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

all those with inline hint.

`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.
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

2 participants