aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock40
-rw-r--r--bin/main.rs29
-rw-r--r--src/plugin.rs11
-rw-r--r--src/plugins/currency.rs1
4 files changed, 54 insertions, 27 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 239bad5..8fe0acc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,23 +1,3 @@
-[root]
-name = "frippy"
-version = "0.2.0"
-dependencies = [
- "clippy 0.0.166 (registry+https://github.com/rust-lang/crates.io-index)",
- "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "irc 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "plugin_derive 0.1.0",
- "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "reqwest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
- "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode_names 0.1.7 (git+https://github.com/Jokler/unicode_names?branch=update-to-latest-unicode)",
-]
-
[[package]]
name = "adler32"
version = "1.0.2"
@@ -293,6 +273,26 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "frippy"
+version = "0.3.0"
+dependencies = [
+ "clippy 0.0.166 (registry+https://github.com/rust-lang/crates.io-index)",
+ "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "irc 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "plugin_derive 0.1.0",
+ "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "reqwest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tokio-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode_names 0.1.7 (git+https://github.com/Jokler/unicode_names?branch=update-to-latest-unicode)",
+]
+
+[[package]]
name = "fuchsia-zircon"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/bin/main.rs b/bin/main.rs
index 18f362e..86910c0 100644
--- a/bin/main.rs
+++ b/bin/main.rs
@@ -8,21 +8,40 @@ struct Logger;
impl log::Log for Logger {
fn enabled(&self, metadata: &LogMetadata) -> bool {
- metadata.level() <= LogLevel::Info
+ metadata.target().contains("frippy")
}
fn log(&self, record: &LogRecord) {
if self.enabled(record.metadata()) {
- println!("[{}]({}) {}", time::now().rfc822(), record.level(), record.args());
+ if record.metadata().level() >= LogLevel::Debug {
+ println!("[{}]({}) {} -> {}",
+ time::now().rfc822(),
+ record.level(),
+ record.target(),
+ record.args());
+ } else {
+ println!("[{}]({}) {}",
+ time::now().rfc822(),
+ record.level(),
+ record.args());
+ }
}
}
}
fn main() {
+
+ let log_level = if cfg!(debug_assertions) {
+ LogLevelFilter::Debug
+ } else {
+ LogLevelFilter::Info
+ };
+
log::set_logger(|max_log_level| {
- max_log_level.set(LogLevelFilter::Info);
- Box::new(Logger)
- }).unwrap();
+ max_log_level.set(log_level);
+ Box::new(Logger)
+ })
+ .unwrap();
frippy::run();
}
diff --git a/src/plugin.rs b/src/plugin.rs
index e0a4ce2..fb35668 100644
--- a/src/plugin.rs
+++ b/src/plugin.rs
@@ -98,6 +98,10 @@ impl ThreadedPlugins {
// Send the message to the plugin if the plugin needs it
if lock_plugin!(plugin).is_allowed(server, &message) {
+ debug!("Executing {} with {}",
+ name,
+ message.to_string().replace("\r\n", ""));
+
// Clone everything before the move
// The server uses an Arc internally too
let plugin = Arc::clone(&plugin);
@@ -114,7 +118,10 @@ impl ThreadedPlugins {
}
}
- pub fn handle_command(&mut self, server: &IrcServer, mut command: PluginCommand) -> Result<(), IrcError> {
+ pub fn handle_command(&mut self,
+ server: &IrcServer,
+ mut command: PluginCommand)
+ -> Result<(), IrcError> {
if !command.tokens.iter().any(|s| !s.is_empty()) {
let help = format!("Use \"{} help\" to get help", server.current_nickname());
@@ -127,6 +134,8 @@ impl ThreadedPlugins {
// The first token contains the name of the plugin
let name = command.tokens.remove(0);
+ debug!("Sending command \"{:?}\" to {}", command, name);
+
// Clone for the move - the server uses an Arc internally
let server = server.clone();
let plugin = Arc::clone(plugin);
diff --git a/src/plugins/currency.rs b/src/plugins/currency.rs
index 78ae593..4ba2531 100644
--- a/src/plugins/currency.rs
+++ b/src/plugins/currency.rs
@@ -1,7 +1,6 @@
extern crate reqwest;
extern crate serde;
extern crate serde_json;
-extern crate regex;
use std::io::Read;
use std::num::ParseFloatError;