mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-18 23:39:30 +00:00
netlink: use features for slog and agent handler
Use features to enable/disable slog and agent handler on demand. This helps to reduce dependency chains if slog/agent handler is unused. Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
This commit is contained in:
2
src/agent/Cargo.lock
generated
2
src/agent/Cargo.lock
generated
@@ -257,8 +257,6 @@ dependencies = [
|
||||
"protocols",
|
||||
"scan_fmt",
|
||||
"slog",
|
||||
"slog-async",
|
||||
"slog-json",
|
||||
"slog-scope",
|
||||
]
|
||||
|
||||
|
@@ -9,10 +9,13 @@ edition = "2018"
|
||||
[dependencies]
|
||||
libc = "0.2.58"
|
||||
nix = "0.17.0"
|
||||
protobuf = "=2.14.0"
|
||||
protocols = { path = "../protocols" }
|
||||
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"
|
||||
|
||||
protobuf = { version = "=2.14.0", optional = true }
|
||||
protocols = { path = "../protocols", optional = true }
|
||||
slog = { version = "2.5.2", features = ["dynamic-keys", "max_level_trace", "release_max_level_info"], optional = true }
|
||||
slog-scope = { version = "4.1.2", optional = true }
|
||||
scan_fmt = "0.2.3"
|
||||
|
||||
[features]
|
||||
with-log = ["slog", "slog-scope"]
|
||||
with-agent-handler = ["protobuf", "protocols"]
|
||||
|
@@ -9,6 +9,7 @@
|
||||
use protobuf::RepeatedField;
|
||||
use protocols::types::{ARPNeighbor, IPAddress, IPFamily, Interface, Route};
|
||||
|
||||
#[cfg(feature = "with-log")]
|
||||
// Convenience macro to obtain the scope logger
|
||||
macro_rules! sl {
|
||||
() => {
|
||||
|
@@ -9,17 +9,18 @@
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_unsafe)]
|
||||
|
||||
mod agent_handler;
|
||||
|
||||
extern crate libc;
|
||||
extern crate nix;
|
||||
|
||||
#[cfg(feature = "with-agent-handler")]
|
||||
extern crate protobuf;
|
||||
#[cfg(feature = "with-agent-handler")]
|
||||
extern crate protocols;
|
||||
|
||||
#[cfg(feature = "with-log")]
|
||||
#[macro_use]
|
||||
extern crate slog;
|
||||
extern crate slog_async;
|
||||
extern crate slog_json;
|
||||
#[cfg(feature = "with-log")]
|
||||
extern crate slog_scope;
|
||||
|
||||
#[macro_use]
|
||||
@@ -33,8 +34,7 @@ use std::mem;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use std::str::FromStr;
|
||||
|
||||
type Result<T> = std::result::Result<T, nix::Error>;
|
||||
|
||||
#[cfg(feature = "with-log")]
|
||||
// Convenience macro to obtain the scope logger
|
||||
macro_rules! sl {
|
||||
() => {
|
||||
@@ -42,6 +42,19 @@ macro_rules! sl {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "with-log"))]
|
||||
#[macro_export]
|
||||
macro_rules! info {
|
||||
($l:expr, #$tag:expr, $($args:tt)*) => {};
|
||||
($l:expr, $($args:tt)*) => {};
|
||||
}
|
||||
|
||||
#[cfg(feature = "with-agent-handler")]
|
||||
mod agent_handler;
|
||||
|
||||
/// Specialized version of std::result::Result for Netlink related operations.
|
||||
pub type Result<T> = std::result::Result<T, nix::Error>;
|
||||
|
||||
// define the struct, const, etc needed by netlink operations
|
||||
|
||||
pub type __s8 = libc::c_char;
|
||||
|
Reference in New Issue
Block a user