log: C++-based backend implementation#14
Conversation
|
The created documentation from the pull request is available at: docu-html |
34f6f12 to
235d8c1
Compare
93febff to
8ff01eb
Compare
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-checkStatus: Click to expand output |
8ff01eb to
a7e0958
Compare
a7e0958 to
50fc165
Compare
50fc165 to
cd7528c
Compare
cd7528c to
872b1af
Compare
b2792db to
dde419b
Compare
dde419b to
018f7f5
Compare
018f7f5 to
8b22ae1
Compare
|
Source code is ready, renames to be done. |
8b22ae1 to
c1ab28e
Compare
c1ab28e to
7f41f28
Compare
7f41f28 to
b950507
Compare
b950507 to
28050b6
Compare
| if (logger->IsLogEnabled(current)) { | ||
| return current; | ||
| } | ||
| } |
There was a problem hiding this comment.
@hoppe-and-dreams dont we have some API to just check it instead of manually resolving it ?
| 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) }; |
There was a problem hiding this comment.
add #safety caluse to all unsafe stuff in this pr
There was a problem hiding this comment.
What i mean is unsafe inside fn requires // Safety: description why its still safe here
2e20e41 to
7e0c59d
Compare
|
|
||
| // Verify configuration. | ||
| #if defined(x86_64_linux) || defined(arm64_qnx) | ||
| static_assert(sizeof(SlotHandle) == 24); |
There was a problem hiding this comment.
We need a comment why 24 . Since it is based on the struct size after padding.
There was a problem hiding this comment.
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}"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()); |
| /// # Safety | ||
| /// | ||
| /// Method sets `MW_LOG_CONFIG_FILE` environment variable. | ||
| /// Setting environment variable is safe only in single-threaded environments. |
There was a problem hiding this comment.
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) }; |
There was a problem hiding this comment.
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}"); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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; |
`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.
7e0c59d to
f37fff3
Compare
…_status Merge current score repo status Signed off by: @antonkrivoborodov
* log: C++-based backend implementation `mw_log` backend implementation using `baselibs`. * log: post-review fixes - 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.
mw_logbackend implementation usingbaselibs.Closes eclipse-score/score#2424