diff options
| author | Jokler <jokler.contact@gmail.com> | 2017-10-16 00:33:58 +0200 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2017-10-16 00:33:58 +0200 |
| commit | a815a897c60a3c9d098b40a39e3d0549d5230b88 (patch) | |
| tree | 1de4e9e1715bf231928c49ab9ceca14a95cd3a20 /bin | |
| parent | 4130d9b299265df7c06a9dcfa426746a870be615 (diff) | |
| download | frippy-a815a897c60a3c9d098b40a39e3d0549d5230b88.tar.gz frippy-a815a897c60a3c9d098b40a39e3d0549d5230b88.zip | |
Rewrite run() and add logging
The logger is created in main.rs for now
and just logs messages over println.
Changes on run()
- Added Log Messages
- Allow multiple configs which create one IrcServer each
- Use tokio-core to keep IrcServers in the main thread
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/main.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/main.rs b/bin/main.rs index b974405..18f362e 100644 --- a/bin/main.rs +++ b/bin/main.rs @@ -1,5 +1,28 @@ extern crate frippy; +extern crate log; +extern crate time; + +use log::{LogRecord, LogLevel, LogLevelFilter, LogMetadata}; + +struct Logger; + +impl log::Log for Logger { + fn enabled(&self, metadata: &LogMetadata) -> bool { + metadata.level() <= LogLevel::Info + } + + fn log(&self, record: &LogRecord) { + if self.enabled(record.metadata()) { + println!("[{}]({}) {}", time::now().rfc822(), record.level(), record.args()); + } + } +} fn main() { + log::set_logger(|max_log_level| { + max_log_level.set(LogLevelFilter::Info); + Box::new(Logger) + }).unwrap(); + frippy::run(); } |
