Skip to content

Commit 77bc368

Browse files
committed
impl: remove log support
Replace `log` crate with `mw_log` and provided Rust backend.
1 parent 7f22bb6 commit 77bc368

File tree

21 files changed

+84
-213
lines changed

21 files changed

+84
-213
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Cargo Clippy
4040
run: |
41-
cargo clippy --all-targets --features logging -- -D warnings
41+
cargo clippy --all-targets --features stdout_logger -- -D warnings
4242
4343
- name: Cargo Fmt
4444
run: |

Cargo.lock

Lines changed: 36 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ edition = "2021"
1515
[workspace.dependencies]
1616
rust_kvs = { path = "src/rust/rust_kvs" }
1717
rust_kvs_tool = { path = "src/rust/rust_kvs_tool" }
18+
mw_log = { git = "https://github.com/eclipse-score/baselibs_rust.git", rev = "7b8ddb142ec4affe9c6a319b60f04302e96004f2", features = [
19+
"qm",
20+
] }
1821

1922
adler32 = "1.2.0"
2023
tinyjson = "2.5.1"

src/rust/rust_kvs/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
1515
rust_library(
1616
name = "rust_kvs",
1717
srcs = glob(["src/**/*.rs"]),
18-
crate_features = ["score-log"],
1918
visibility = ["//visibility:public"],
2019
deps = [
2120
"@score_baselibs_rust//src/log/mw_log",
@@ -27,7 +26,6 @@ rust_library(
2726
rust_test(
2827
name = "tests",
2928
crate = "rust_kvs",
30-
crate_features = ["score-log"],
3129
tags = [
3230
"unit_tests",
3331
"ut",

src/rust/rust_kvs/Cargo.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ edition.workspace = true
77
[dependencies]
88
adler32.workspace = true
99
tinyjson.workspace = true
10-
log = { version = "0.4.29", optional = true }
11-
12-
13-
[features]
14-
default = ["logging"]
15-
score-log = []
16-
logging = ["log"]
10+
mw_log.workspace = true
1711

1812

1913
[dev-dependencies]

src/rust/rust_kvs/src/error_code.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111

1212
extern crate alloc;
1313

14-
use crate::log::error;
1514
use alloc::string::FromUtf8Error;
1615
use core::array::TryFromSliceError;
16+
use mw_log::error;
1717

1818
/// Runtime Error Codes
19-
#[derive(Debug, PartialEq)]
20-
#[cfg_attr(feature = "score-log", derive(mw_log::ScoreDebug))]
19+
#[derive(Debug, PartialEq, mw_log::ScoreDebug)]
2120
pub enum ErrorCode {
2221
/// Error that was not yet mapped
2322
UnmappedError,

src/rust/rust_kvs/src/json_backend.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::error_code::ErrorCode;
1313
use crate::kvs_api::{InstanceId, SnapshotId};
1414
use crate::kvs_backend::KvsBackend;
1515
use crate::kvs_value::{KvsMap, KvsValue};
16-
use crate::log::{debug, error, trace};
16+
use mw_log::{debug, error, trace};
1717
use std::collections::HashMap;
1818
use std::fs;
1919
use std::path::{Path, PathBuf};
@@ -200,8 +200,7 @@ impl Default for JsonBackendBuilder {
200200
}
201201

202202
/// KVS backend implementation based on TinyJSON.
203-
#[derive(Clone, Debug, PartialEq)]
204-
#[cfg_attr(feature = "score-log", derive(mw_log::ScoreDebug))]
203+
#[derive(Clone, Debug, PartialEq, mw_log::ScoreDebug)]
205204
pub struct JsonBackend {
206205
working_dir: PathBuf,
207206
snapshot_max_count: usize,

src/rust/rust_kvs/src/kvs.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
// SPDX-License-Identifier: Apache-2.0
1111

1212
use crate::error_code::ErrorCode;
13-
use crate::kvs_api::{DebugT, InstanceId, KvsApi, KvsDefaults, KvsLoad, SnapshotId};
13+
use crate::kvs_api::{InstanceId, KvsApi, KvsDefaults, KvsLoad, SnapshotId};
1414
use crate::kvs_backend::KvsBackend;
1515
use crate::kvs_builder::KvsData;
1616
use crate::kvs_value::{KvsMap, KvsValue};
17-
use crate::log::{error, warn};
17+
use mw_log::{error, fmt::ScoreDebug, warn};
1818
use std::sync::{Arc, Mutex};
1919

2020
/// KVS instance parameters.
21-
#[derive(Debug)]
22-
#[cfg_attr(feature = "score-log", derive(mw_log::ScoreDebug))]
21+
#[derive(mw_log::ScoreDebug)]
2322
pub struct KvsParameters {
2423
/// Instance ID.
2524
pub instance_id: InstanceId,
@@ -153,7 +152,7 @@ impl KvsApi for Kvs {
153152
fn get_value_as<T>(&self, key: &str) -> Result<T, ErrorCode>
154153
where
155154
for<'a> T: TryFrom<&'a KvsValue>,
156-
for<'a> <T as TryFrom<&'a KvsValue>>::Error: DebugT,
155+
for<'a> <T as TryFrom<&'a KvsValue>>::Error: ScoreDebug,
157156
{
158157
let data = self.data.lock()?;
159158
if let Some(value) = data.kvs_map.get(key) {
@@ -349,8 +348,7 @@ mod kvs_tests {
349348

350349
/// Most tests can be performed with mocked backend.
351350
/// Only those with file handling must use concrete implementation.
352-
#[derive(PartialEq, Debug)]
353-
#[cfg_attr(feature = "score-log", derive(mw_log::ScoreDebug))]
351+
#[derive(PartialEq, Debug, mw_log::ScoreDebug)]
354352
struct MockBackend;
355353

356354
impl KvsBackend for MockBackend {

0 commit comments

Comments
 (0)