geckodriver: logging: ignore records from other modules
authorAndreas Tolfsen <ato@mozilla.com>
Wed, 12 Apr 2017 15:19:25 +0100
changeset 581792 a59a086eb99ba812e866ca834ba05b001ac0e24f
parent 581791 d62542532dc1b6a196b6f24a821e1fa08de6fe27
child 581793 1020c55942f25da88fd8ad29eaf40a056bb7d69c
push id59896
push userhikezoe@mozilla.com
push dateFri, 19 May 2017 23:30:01 +0000
milestone55.0a1
geckodriver: logging: ignore records from other modules This effectively filters out all log entries from modules that do not begin with either "geckodriver" or "webdriver". This is a big hack, but works well enough for the time being. Source-Repo: https://github.com/mozilla/geckodriver Source-Revision: baf5451f402be11df5a41df1fc7893ea8e85cb45 committer: jgraham <james@hoppipolla.co.uk>
testing/geckodriver/src/logging.rs
--- a/testing/geckodriver/src/logging.rs
+++ b/testing/geckodriver/src/logging.rs
@@ -122,24 +122,24 @@ fn filtered_gecko_log(level: &LogLevel) 
     let io = stream(io::stderr(), GeckoFormat {});
     slog::level_filter(level.to_slog(), io)
 }
 
 struct GeckoFormat;
 
 impl Format for GeckoFormat {
     fn format(&self, io: &mut io::Write, record: &Record, _: &OwnedKeyValueList) -> io::Result<()> {
-        let ts = format_ts(Local::now());
-        let level = record.level().to_gecko();
-        let _ = try!(write!(io,
-                            "{}\t{}\t{}\t{}\n",
-                            ts,
-                            record.module(),
-                            level,
-                            record.msg()));
+        // TODO(ato): Quite sure this is the wrong way to filter records with slog,
+        // but I do not comprehend how slog works.
+        let module = record.module();
+        if module.starts_with("geckodriver") || module.starts_with("webdriver") {
+            let ts = format_ts(Local::now());
+            let level = record.level().to_gecko();
+            let _ = try!(write!(io, "{}\t{}\t{}\t{}\n", ts, module, level, record.msg()));
+        }
         Ok(())
     }
 }
 
 /// Produces a 13-digit Unix Epoch timestamp similar to Gecko.
 fn format_ts(ts: DateTime<Local>) -> String {
     format!("{}{:03}", ts.timestamp(), ts.timestamp_subsec_millis())
 }