Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.

Commit cebb14c

Browse files
Drop serde_json dependency and log more
1 parent d0966e9 commit cebb14c

File tree

3 files changed

+7
-32
lines changed

3 files changed

+7
-32
lines changed

Cargo.lock

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ log = "0.3.6"
1212
lru-cache = "0.0.7"
1313
router = "0.1.1"
1414
rustc-serialize = "0.3.19"
15-
serde_json = "0.7.1"
1615
staticfile = "0.2.0"
1716
toml = "0.1.30"
1817
unicase = "1.4.0"

src/bin/playbot.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ extern crate irc;
66
extern crate toml;
77
extern crate hyper;
88
extern crate url;
9-
extern crate serde_json as json;
9+
extern crate rustc_serialize;
1010

1111
use rust_playpen::ReleaseChannel;
1212

1313
use irc::client::prelude::*;
1414
use url::form_urlencoded;
1515
use hyper::client::Client;
16+
use rustc_serialize::json;
1617

1718
use std::fs::{self, File};
1819
use std::io::{self, Read};
@@ -74,10 +75,10 @@ impl Playbot {
7475
let mut response = try!(client.get(&url).send());
7576
let mut body = String::new();
7677
try!(response.read_to_string(&mut body));
77-
let value: json::Value = json::from_str(&body).unwrap();
78+
let value: json::Json = json::Json::from_str(&body).unwrap();
7879
let obj = value.as_object().unwrap();
7980
if obj["status_txt"].as_string().unwrap() == "OK" {
80-
Ok(String::from(value.lookup("data.url").unwrap().as_string().unwrap()))
81+
Ok(String::from(value.find_path(&["data", "url"]).unwrap().as_string().unwrap()))
8182
} else {
8283
Err(io::Error::new(io::ErrorKind::Other,
8384
format!("server responded with: {}", body)).into())
@@ -139,7 +140,7 @@ fn main() {{
139140
Ok(short_url) => response.push_str(&format!("\n(output truncated; full output at {})",
140141
short_url)),
141142
Err(e) => {
142-
log_error(e);
143+
error!("shortening url failed: {}", e);
143144
response.push_str("\n(output truncated; shortening URL failed)");
144145
}
145146
}
@@ -153,13 +154,13 @@ fn main() {{
153154
for line in response.lines() {
154155
if !line.is_empty() {
155156
if let Err(e) = self.conn.send_notice(response_to, line) {
156-
log_error(e);
157+
error!("couldn't send response: {}", e);
157158
}
158159
}
159160
}
160161
}
161162
Err(e) => {
162-
log_error(e);
163+
error!("{}", e);
163164
}
164165
}
165166
}
@@ -214,11 +215,6 @@ fn main() {{
214215
}
215216
}
216217

217-
/// Log and forget an error
218-
fn log_error<E: Error>(e: E) {
219-
println!("[ERROR] {}", e);
220-
}
221-
222218
fn main() {
223219
env_logger::init().unwrap();
224220

0 commit comments

Comments
 (0)