mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 15:32:30 +00:00
agent: separate logging into a single crate
Since the codes in logging.rs is weakly related to the project, separating it from the project will reduce coupling and make it reusable. Fixes: #131 Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
parent
b5e741ba8b
commit
c373f846f5
@ -6,6 +6,7 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
oci = { path = "oci" }
|
oci = { path = "oci" }
|
||||||
|
logging = { path = "logging" }
|
||||||
rustjail = { path = "rustjail" }
|
rustjail = { path = "rustjail" }
|
||||||
protocols = { path = "protocols" }
|
protocols = { path = "protocols" }
|
||||||
netlink = { path = "netlink" }
|
netlink = { path = "netlink" }
|
||||||
@ -27,8 +28,6 @@ regex = "1"
|
|||||||
# - The 'max_*' features allow changing the log level at runtime
|
# - The 'max_*' features allow changing the log level at runtime
|
||||||
# (by stopping the compiler from removing log calls).
|
# (by stopping the compiler from removing log calls).
|
||||||
slog = { version = "2.5.2", features = ["dynamic-keys", "max_level_trace", "release_max_level_info"] }
|
slog = { version = "2.5.2", features = ["dynamic-keys", "max_level_trace", "release_max_level_info"] }
|
||||||
slog-json = "2.3.0"
|
|
||||||
slog-async = "2.3.0"
|
|
||||||
slog-scope = "4.1.2"
|
slog-scope = "4.1.2"
|
||||||
# for testing
|
# for testing
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
|
20
src/agent/logging/Cargo.toml
Normal file
20
src/agent/logging/Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[package]
|
||||||
|
name = "logging"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Tim Zhang <tim@hyper.sh>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde_json = "1.0.39"
|
||||||
|
# slog:
|
||||||
|
# - Dynamic keys required to allow HashMap keys to be slog::Serialized.
|
||||||
|
# - The 'max_*' features allow changing the log level at runtime
|
||||||
|
# (by stopping the compiler from removing log calls).
|
||||||
|
slog = { version = "2.5.2", features = ["dynamic-keys", "max_level_trace", "release_max_level_info"] }
|
||||||
|
slog-json = "2.3.0"
|
||||||
|
slog-async = "2.3.0"
|
||||||
|
slog-scope = "4.1.2"
|
||||||
|
# for testing
|
||||||
|
tempfile = "3.1.0"
|
@ -2,6 +2,8 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
#[macro_use]
|
||||||
|
extern crate slog;
|
||||||
|
|
||||||
use slog::{BorrowedKV, Drain, Key, OwnedKV, OwnedKVList, Record, KV};
|
use slog::{BorrowedKV, Drain, Key, OwnedKV, OwnedKVList, Record, KV};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -146,12 +148,6 @@ impl<D> RuntimeLevelFilter<D> {
|
|||||||
level: Mutex::new(level),
|
level: Mutex::new(level),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_level(&self, level: slog::Level) {
|
|
||||||
let mut log_level = self.level.lock().unwrap();
|
|
||||||
|
|
||||||
*log_level = level;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D> Drain for RuntimeLevelFilter<D>
|
impl<D> Drain for RuntimeLevelFilter<D>
|
@ -25,8 +25,6 @@ extern crate scopeguard;
|
|||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate slog;
|
extern crate slog;
|
||||||
extern crate slog_async;
|
|
||||||
extern crate slog_json;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate netlink;
|
extern crate netlink;
|
||||||
|
|
||||||
@ -50,7 +48,6 @@ use unistd::Pid;
|
|||||||
mod config;
|
mod config;
|
||||||
mod device;
|
mod device;
|
||||||
mod linux_abi;
|
mod linux_abi;
|
||||||
mod logging;
|
|
||||||
mod mount;
|
mod mount;
|
||||||
mod namespace;
|
mod namespace;
|
||||||
mod network;
|
mod network;
|
||||||
|
Loading…
Reference in New Issue
Block a user