chiark / gitweb /
format log better
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 29 Dec 2020 01:21:51 +0000 (01:21 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 29 Dec 2020 01:21:51 +0000 (01:21 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
wdriver.rs

index dc98721978d0515dbec9bbcca30c6fda648cd29e..2da630d4703de355b567ccdf3d91effaf2668db0 100644 (file)
@@ -24,6 +24,7 @@ pub use void::Void;
 pub use t4::WebDriverCommands;
 
 pub use std::env;
+pub use std::fmt;
 pub use std::fs;
 pub use std::collections::hash_map::HashMap;
 pub use std::convert::TryInto;
@@ -708,12 +709,18 @@ fn fetch_log(driver: &T4d, name: &str) {
     {
       #[derive(Deserialize)]
       struct LogEnt(String, Vec<serde_json::Value>);
+      impl fmt::Display for LogEnt {
+        #[throws(fmt::Error)]
+        fn fmt(&self, f: &mut fmt::Formatter) {
+          write!(f, "{}:", self.0)?;
+          for a in &self.1 { write!(f, " {}", a)?; }
+        }
+      }
 
       let ent: LogEnt = serde_json::from_value(ent.clone())
         .context("parse log entry")?;
-      eprint!("JS {} {}:", name, &ent.0);
-      for a in ent.1 { eprint!(" {}", a); }
-      eprintln!("");
+
+      debug!("JS {} {}", name, &ent);
     }
     Ok::<_,AE>(())
   })()