Browse Source

aya-log, test: Switch from simplelog to env_logger

Signed-off-by: Michal Rostecki <[email protected]>
Michal Rostecki 2 years ago
parent
commit
3664e1e
5 changed files with 10 additions and 39 deletions
  1. 1 1
      aya-log/Cargo.toml
  2. 3 13
      aya-log/README.md
  3. 4 14
      aya-log/src/lib.rs
  4. 1 1
      test/integration-test/Cargo.toml
  5. 1 10
      test/integration-test/src/main.rs

+ 1 - 1
aya-log/Cargo.toml

@@ -20,7 +20,7 @@ bytes = "1.1"
 tokio = { version = "1.2.0" }
 
 [dev-dependencies]
-simplelog = "0.12"
+env_logger = "0.9"
 testing_logger = "0.1.1"
 
 [lib]

+ 3 - 13
aya-log/README.md

@@ -27,25 +27,15 @@ aya-log-ebpf = { git = "https://github.com/aya-rs/aya-log", branch = "main" }
 
 ## Example
 
-Here's an example that uses `aya-log` in conjunction with the [simplelog] crate
+Here's an example that uses `aya-log` in conjunction with the [env_logger] crate
 to log eBPF messages to the terminal.
 
 ### User space code
 
 ```rust
-use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
 use aya_log::BpfLogger;
 
-TermLogger::init(
-    LevelFilter::Debug,
-    ConfigBuilder::new()
-        .set_target_level(LevelFilter::Error)
-        .set_location_level(LevelFilter::Error)
-        .build(),
-    TerminalMode::Mixed,
-    ColorChoice::Auto,
-)
-.unwrap();
+env_logger::init();
 
 // Will log using the default logger, which is TermLogger in this case
 BpfLogger::init(&mut bpf).unwrap();
@@ -70,4 +60,4 @@ fn try_xdp_firewall(ctx: XdpContext) -> Result<u32, ()> {
 
 [aya]: https://github.com/aya-rs/aya
 [log]: https://docs.rs/log
-[simplelog]: https://docs.rs/simplelog
+[env_logger]: https://docs.rs/env_logger

+ 4 - 14
aya-log/src/lib.rs

@@ -9,24 +9,14 @@
 //!
 //! # Example:
 //!
-//! This example uses the [simplelog] crate to log messages to the terminal.
+//! This example uses the [env_logger] crate to log messages to the terminal.
 //!
 //! ```no_run
 //! # let mut bpf = aya::Bpf::load(&[]).unwrap();
-//! use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
 //! use aya_log::BpfLogger;
 //!
-//! // initialize simplelog::TermLogger as the default logger
-//! TermLogger::init(
-//!     LevelFilter::Debug,
-//!     ConfigBuilder::new()
-//!         .set_target_level(LevelFilter::Error)
-//!         .set_location_level(LevelFilter::Error)
-//!         .build(),
-//!     TerminalMode::Mixed,
-//!     ColorChoice::Auto,
-//! )
-//! .unwrap();
+//! // initialize env_logger as the default logger
+//! env_logger::init();
 //!
 //! // start reading aya-log records and log them using the default logger
 //! BpfLogger::init(&mut bpf).unwrap();
@@ -55,7 +45,7 @@
 //! ```
 //!
 //! [Aya]: https://docs.rs/aya
-//! [simplelog]: https://docs.rs/simplelog
+//! [env_logger]: https://docs.rs/env_logger
 //! [Log]: https://docs.rs/log/0.4.14/log/trait.Log.html
 //! [log]: https://docs.rs/log
 //!

+ 1 - 1
test/integration-test/Cargo.toml

@@ -14,4 +14,4 @@ libc = { version = "0.2.105" }
 log = "0.4"
 object = { version = "0.29", default-features = false, features = ["std", "read_core", "elf"] }
 regex = "1"
-simplelog = "0.12"
+env_logger = "0.9"

+ 1 - 10
test/integration-test/src/main.rs

@@ -1,19 +1,10 @@
 use log::info;
-use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
 
 mod tests;
 use tests::IntegrationTest;
 
 fn main() -> anyhow::Result<()> {
-    TermLogger::init(
-        LevelFilter::Debug,
-        ConfigBuilder::new()
-            .set_target_level(LevelFilter::Error)
-            .set_location_level(LevelFilter::Error)
-            .build(),
-        TerminalMode::Mixed,
-        ColorChoice::Auto,
-    )?;
+    env_logger::init();
 
     // Run the tests
     for t in inventory::iter::<IntegrationTest> {