mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use debug instead of println in devtools
This commit is contained in:
parent
4dcb05ca4f
commit
48257ef282
8 changed files with 17 additions and 11 deletions
|
@ -19,3 +19,4 @@ serde = "0.7"
|
||||||
serde_json = "0.7"
|
serde_json = "0.7"
|
||||||
serde_macros = "0.7"
|
serde_macros = "0.7"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
|
log = "0.3.5"
|
||||||
|
|
|
@ -92,7 +92,7 @@ impl ActorRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register_script_actor(&self, script_id: String, actor: String) {
|
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();
|
let mut script_actors = self.script_actors.borrow_mut();
|
||||||
script_actors.insert(script_id, actor);
|
script_actors.insert(script_id, actor);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ impl ActorRegistry {
|
||||||
|
|
||||||
pub fn actor_to_script(&self, actor: String) -> String {
|
pub fn actor_to_script(&self, actor: String) -> String {
|
||||||
for (key, value) in &*self.script_actors.borrow() {
|
for (key, value) in &*self.script_actors.borrow() {
|
||||||
println!("checking {}", value);
|
debug!("checking {}", value);
|
||||||
if *value == actor {
|
if *value == actor {
|
||||||
return key.to_owned();
|
return key.to_owned();
|
||||||
}
|
}
|
||||||
|
@ -156,12 +156,12 @@ impl ActorRegistry {
|
||||||
let to = msg.get("to").unwrap().as_string().unwrap();
|
let to = msg.get("to").unwrap().as_string().unwrap();
|
||||||
|
|
||||||
match self.actors.get(to) {
|
match self.actors.get(to) {
|
||||||
None => println!("message received for unknown actor \"{}\"", to),
|
None => debug!("message received for unknown actor \"{}\"", to),
|
||||||
Some(actor) => {
|
Some(actor) => {
|
||||||
let msg_type = msg.get("type").unwrap().as_string().unwrap();
|
let msg_type = msg.get("type").unwrap().as_string().unwrap();
|
||||||
if try!(actor.handle_message(self, msg_type, msg, stream))
|
if try!(actor.handle_message(self, msg_type, msg, stream))
|
||||||
!= ActorMessageStatus::Processed {
|
!= ActorMessageStatus::Processed {
|
||||||
println!("unexpected message type \"{}\" found for actor \"{}\"",
|
debug!("unexpected message type \"{}\" found for actor \"{}\"",
|
||||||
msg_type, to);
|
msg_type, to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl Actor for ConsoleActor {
|
||||||
match str_type {
|
match str_type {
|
||||||
"PageError" => message_types.insert(PAGE_ERROR),
|
"PageError" => message_types.insert(PAGE_ERROR),
|
||||||
"ConsoleAPI" => message_types.insert(CONSOLE_API),
|
"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();
|
let (chan, port) = ipc::channel().unwrap();
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
extern crate devtools_traits;
|
extern crate devtools_traits;
|
||||||
extern crate hyper;
|
extern crate hyper;
|
||||||
extern crate ipc_channel;
|
extern crate ipc_channel;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
extern crate msg;
|
extern crate msg;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
@ -204,7 +206,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
|
|
||||||
/// Process the input from a single devtools client until EOF.
|
/// Process the input from a single devtools client until EOF.
|
||||||
fn handle_client(actors: Arc<Mutex<ActorRegistry>>, mut stream: TcpStream) {
|
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 actors = actors.lock().unwrap();
|
||||||
let msg = actors.find::<RootActor>("root").encodable();
|
let msg = actors.find::<RootActor>("root").encodable();
|
||||||
|
@ -218,18 +220,18 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
&mut stream) {
|
&mut stream) {
|
||||||
Ok(()) => {},
|
Ok(()) => {},
|
||||||
Err(()) => {
|
Err(()) => {
|
||||||
println!("error: devtools actor stopped responding");
|
debug!("error: devtools actor stopped responding");
|
||||||
let _ = stream.shutdown(Shutdown::Both);
|
let _ = stream.shutdown(Shutdown::Both);
|
||||||
break 'outer
|
break 'outer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
println!("error: EOF");
|
debug!("error: EOF");
|
||||||
break 'outer
|
break 'outer
|
||||||
}
|
}
|
||||||
Err(err_msg) => {
|
Err(err_msg) => {
|
||||||
println!("error: {}", err_msg);
|
debug!("error: {}", err_msg);
|
||||||
break 'outer
|
break 'outer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub trait JsonPacketStream {
|
||||||
impl JsonPacketStream for TcpStream {
|
impl JsonPacketStream for TcpStream {
|
||||||
fn write_json_packet<T: Serialize>(&mut self, obj: &T) {
|
fn write_json_packet<T: Serialize>(&mut self, obj: &T) {
|
||||||
let s = serde_json::to_string(obj).unwrap();
|
let s = serde_json::to_string(obj).unwrap();
|
||||||
println!("<- {}", s);
|
debug!("<- {}", s);
|
||||||
write!(self, "{}:{}", s.len(), s).unwrap();
|
write!(self, "{}:{}", s.len(), s).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ impl JsonPacketStream for TcpStream {
|
||||||
};
|
};
|
||||||
let mut packet = String::new();
|
let mut packet = String::new();
|
||||||
self.take(packet_len).read_to_string(&mut packet).unwrap();
|
self.take(packet_len).read_to_string(&mut packet).unwrap();
|
||||||
println!("{}", packet);
|
debug!("{}", packet);
|
||||||
return match serde_json::from_str(&packet) {
|
return match serde_json::from_str(&packet) {
|
||||||
Ok(json) => Ok(Some(json)),
|
Ok(json) => Ok(Some(json)),
|
||||||
Err(err) => match err {
|
Err(err) => match err {
|
||||||
|
|
1
components/servo/Cargo.lock
generated
1
components/servo/Cargo.lock
generated
|
@ -479,6 +479,7 @@ dependencies = [
|
||||||
"devtools_traits 0.0.1",
|
"devtools_traits 0.0.1",
|
||||||
"hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
1
ports/cef/Cargo.lock
generated
1
ports/cef/Cargo.lock
generated
|
@ -441,6 +441,7 @@ dependencies = [
|
||||||
"devtools_traits 0.0.1",
|
"devtools_traits 0.0.1",
|
||||||
"hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
1
ports/gonk/Cargo.lock
generated
1
ports/gonk/Cargo.lock
generated
|
@ -443,6 +443,7 @@ dependencies = [
|
||||||
"devtools_traits 0.0.1",
|
"devtools_traits 0.0.1",
|
||||||
"hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue