Use debug instead of println in devtools

This commit is contained in:
Manish Goregaokar 2016-05-27 15:09:26 +05:30
parent 4dcb05ca4f
commit 48257ef282
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
8 changed files with 17 additions and 11 deletions

View file

@ -19,3 +19,4 @@ serde = "0.7"
serde_json = "0.7"
serde_macros = "0.7"
time = "0.1"
log = "0.3.5"

View file

@ -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);
}
}

View file

@ -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();

View file

@ -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
}
}

View file

@ -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 {

View file

@ -479,6 +479,7 @@ dependencies = [
"devtools_traits 0.0.1",
"hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.2 (git+https://github.com/servo/ipc-channel)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"plugins 0.0.1",
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",

1
ports/cef/Cargo.lock generated
View file

@ -441,6 +441,7 @@ dependencies = [
"devtools_traits 0.0.1",
"hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.2 (git+https://github.com/servo/ipc-channel)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"plugins 0.0.1",
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",

1
ports/gonk/Cargo.lock generated
View file

@ -443,6 +443,7 @@ dependencies = [
"devtools_traits 0.0.1",
"hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.2 (git+https://github.com/servo/ipc-channel)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"plugins 0.0.1",
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",