chiark / gitweb /
logging
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 24 Dec 2020 01:24:25 +0000 (01:24 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 24 Dec 2020 01:24:25 +0000 (01:24 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock.example
wdriver.rs
wdriver/Cargo.toml

index 6b157bb65b7aab598f11266cf5d6b72da90daa46..7f1d659361251a81aa414e5e9ea3527bc5c5f997 100644 (file)
@@ -485,6 +485,19 @@ dependencies = [
  "cfg-if 1.0.0",
 ]
 
+[[package]]
+name = "env_logger"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd"
+dependencies = [
+ "atty",
+ "humantime",
+ "log 0.4.11",
+ "regex",
+ "termcolor",
+]
+
 [[package]]
 name = "erased-serde"
 version = "0.3.12"
@@ -1562,9 +1575,11 @@ name = "otter-webdriver-tests"
 version = "0.0.1"
 dependencies = [
  "anyhow",
+ "env_logger",
  "fehler",
  "humantime",
  "libc",
+ "log 0.4.11",
  "nix 0.19.1",
  "otter",
  "structopt",
@@ -2467,6 +2482,15 @@ dependencies = [
  "url 1.7.2",
 ]
 
+[[package]]
+name = "termcolor"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
+dependencies = [
+ "winapi-util",
+]
+
 [[package]]
 name = "textwrap"
 version = "0.11.0"
index e18732050f6638b9ecc38ec7d30a6664399e3812..0dc7b980aac1d0947ce9294cc2c6ca5754094117 100644 (file)
@@ -4,9 +4,11 @@
 
 pub use anyhow::{anyhow, Context};
 pub use fehler::{throw, throws};
+pub use log::{debug, error, info, trace, warn};
+pub use log::{log, log_enabled};
+pub use nix::unistd::LinkatFlags;
 pub use structopt::StructOpt;
 pub use thirtyfour_sync as t4;
-use nix::unistd::LinkatFlags;
 pub use void::Void;
 
 pub use t4::WebDriverCommands;
@@ -40,7 +42,7 @@ where Self: anyhow::Context<T,E>
 {
   fn always_context(self, msg: &'static str) -> anyhow::Result<T> {
     let x = self.context(msg);
-    if x.is_ok() { eprintln!("completed {}.", msg) };
+    if x.is_ok() { info!("completed {}.", msg) };
     x
   }
   fn just_warn(self, msg: &'static str) -> Option<T> {
@@ -444,6 +446,15 @@ impl Drop for FinalInfoCollection {
 
 #[throws(AE)]
 pub fn setup() -> Setup {
+  env_logger::Builder::new()
+    .format_timestamp_micros()
+    .format_level(true)
+    .filter_module("otter_webdriver_tests", log::LevelFilter::Debug)
+    .filter_level(log::LevelFilter::Info)
+    .parse_env("OTTER_WDT_LOG")
+    .init();
+  debug!("starting");
+
   let current_exe : String = env::current_exe()
     .context("find current executable")?
     .to_str()
index 4e448ab06d4088ef8f9727483411eeb6ea85c275..601f01402fb1639d1487babf67ddd056386392a3 100644 (file)
@@ -14,8 +14,10 @@ edition = "2018"
 otter = { path = ".." }
 
 anyhow = "1"
+env_logger = "0.8"
 fehler = "1"
 humantime = "2"
+log = "0.4"
 libc = "0.2"
 nix = "0.19"
 structopt = "0.3"