diff options
Diffstat (limited to 'components/devtools')
-rw-r--r-- | components/devtools/Cargo.toml | 1 | ||||
-rw-r--r-- | components/devtools/actor.rs | 8 | ||||
-rw-r--r-- | components/devtools/actors/console.rs | 2 | ||||
-rw-r--r-- | components/devtools/lib.rs | 10 | ||||
-rw-r--r-- | components/devtools/protocol.rs | 4 |
5 files changed, 14 insertions, 11 deletions
diff --git a/components/devtools/Cargo.toml b/components/devtools/Cargo.toml index 808fcfa5646..099b71edd3e 100644 --- a/components/devtools/Cargo.toml +++ b/components/devtools/Cargo.toml @@ -19,3 +19,4 @@ serde = "0.7" serde_json = "0.7" serde_macros = "0.7" time = "0.1" +log = "0.3.5" diff --git a/components/devtools/actor.rs b/components/devtools/actor.rs index 6ddb45335ee..c439ad0e028 100644 --- a/components/devtools/actor.rs +++ b/components/devtools/actor.rs @@ -92,7 +92,7 @@ impl ActorRegistry { } pub fn register_script_actor(&self, script_id: String, actor: String) { - println!("registering {} ({})", actor, script_id); + debug!("registering {} ({})", actor, script_id); let mut script_actors = self.script_actors.borrow_mut(); script_actors.insert(script_id, actor); } @@ -110,7 +110,7 @@ impl ActorRegistry { pub fn actor_to_script(&self, actor: String) -> String { for (key, value) in &*self.script_actors.borrow() { - println!("checking {}", value); + debug!("checking {}", value); if *value == actor { return key.to_owned(); } @@ -156,12 +156,12 @@ impl ActorRegistry { let to = msg.get("to").unwrap().as_string().unwrap(); match self.actors.get(to) { - None => println!("message received for unknown actor \"{}\"", to), + None => debug!("message received for unknown actor \"{}\"", to), Some(actor) => { let msg_type = msg.get("type").unwrap().as_string().unwrap(); if try!(actor.handle_message(self, msg_type, msg, stream)) != ActorMessageStatus::Processed { - println!("unexpected message type \"{}\" found for actor \"{}\"", + debug!("unexpected message type \"{}\" found for actor \"{}\"", msg_type, to); } } diff --git a/components/devtools/actors/console.rs b/components/devtools/actors/console.rs index 48c38d1cd47..d6cfbe10f51 100644 --- a/components/devtools/actors/console.rs +++ b/components/devtools/actors/console.rs @@ -110,7 +110,7 @@ impl Actor for ConsoleActor { match str_type { "PageError" => message_types.insert(PAGE_ERROR), "ConsoleAPI" => message_types.insert(CONSOLE_API), - s => println!("unrecognized message type requested: \"{}\"", s), + s => debug!("unrecognized message type requested: \"{}\"", s), }; }; let (chan, port) = ipc::channel().unwrap(); diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 3aad044b485..d8e54ddad62 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -23,6 +23,8 @@ extern crate devtools_traits; extern crate hyper; extern crate ipc_channel; +#[macro_use] +extern crate log; extern crate msg; extern crate serde; extern crate serde_json; @@ -204,7 +206,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, /// Process the input from a single devtools client until EOF. fn handle_client(actors: Arc<Mutex<ActorRegistry>>, mut stream: TcpStream) { - println!("connection established to {}", stream.peer_addr().unwrap()); + debug!("connection established to {}", stream.peer_addr().unwrap()); { let actors = actors.lock().unwrap(); let msg = actors.find::<RootActor>("root").encodable(); @@ -218,18 +220,18 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, &mut stream) { Ok(()) => {}, Err(()) => { - println!("error: devtools actor stopped responding"); + debug!("error: devtools actor stopped responding"); let _ = stream.shutdown(Shutdown::Both); break 'outer } } } Ok(None) => { - println!("error: EOF"); + debug!("error: EOF"); break 'outer } Err(err_msg) => { - println!("error: {}", err_msg); + debug!("error: {}", err_msg); break 'outer } } diff --git a/components/devtools/protocol.rs b/components/devtools/protocol.rs index 53975bc3501..cb75572f3b8 100644 --- a/components/devtools/protocol.rs +++ b/components/devtools/protocol.rs @@ -20,7 +20,7 @@ pub trait JsonPacketStream { impl JsonPacketStream for TcpStream { fn write_json_packet<T: Serialize>(&mut self, obj: &T) { let s = serde_json::to_string(obj).unwrap(); - println!("<- {}", s); + debug!("<- {}", s); write!(self, "{}:{}", s.len(), s).unwrap(); } @@ -48,7 +48,7 @@ impl JsonPacketStream for TcpStream { }; let mut packet = String::new(); self.take(packet_len).read_to_string(&mut packet).unwrap(); - println!("{}", packet); + debug!("{}", packet); return match serde_json::from_str(&packet) { Ok(json) => Ok(Some(json)), Err(err) => match err { |