Added logging support via the log crate.
This commit is contained in:
parent
2a11e63725
commit
7625c364a6
4 changed files with 8 additions and 1 deletions
|
@ -27,6 +27,7 @@ chrono = "0.4"
|
|||
encoding = "0.2"
|
||||
error-chain = "0.10"
|
||||
futures = "0.1"
|
||||
log = "0.3"
|
||||
native-tls = "0.1"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
|
|
|
@ -109,6 +109,7 @@ impl Connection {
|
|||
Ok(ConnectionFuture::Mock(config))
|
||||
} else if config.use_ssl() {
|
||||
let domain = format!("{}", config.server());
|
||||
info!("Connecting via SSL to {}.", domain);
|
||||
let mut builder = TlsConnector::builder()?;
|
||||
if let Some(cert_path) = config.cert_path() {
|
||||
let mut file = File::open(cert_path)?;
|
||||
|
@ -116,7 +117,7 @@ impl Connection {
|
|||
file.read_to_end(&mut cert_data)?;
|
||||
let cert = Certificate::from_der(&cert_data)?;
|
||||
builder.add_root_certificate(cert)?;
|
||||
println!("Added {} to trusted certificates.", cert_path);
|
||||
info!("Added {} to trusted certificates.", cert_path);
|
||||
}
|
||||
let connector = builder.build()?;
|
||||
let stream = Box::new(TcpStream::connect(&config.socket_addr()?, handle)
|
||||
|
@ -132,6 +133,7 @@ impl Connection {
|
|||
));
|
||||
Ok(ConnectionFuture::Secured(config, stream))
|
||||
} else {
|
||||
info!("Connecting to {}.", config.server());
|
||||
Ok(ConnectionFuture::Unsecured(
|
||||
config,
|
||||
TcpStream::connect(&config.socket_addr()?, handle),
|
||||
|
|
|
@ -333,6 +333,7 @@ impl ServerState {
|
|||
|
||||
/// Handles sent messages internally for basic client functionality.
|
||||
fn handle_sent_message(&self, msg: &Message) -> error::Result<()> {
|
||||
trace!("[SENT] {}", msg.to_string());
|
||||
match msg.command {
|
||||
PART(ref chan, _) => {
|
||||
let _ = self.chanlists.lock().unwrap().remove(chan);
|
||||
|
@ -344,6 +345,7 @@ impl ServerState {
|
|||
|
||||
/// Handles received messages internally for basic client functionality.
|
||||
fn handle_message(&self, msg: &Message) -> error::Result<()> {
|
||||
trace!("[RECV] {}", msg.to_string());
|
||||
match msg.command {
|
||||
JOIN(ref chan, _, _) => self.handle_join(msg.source_nickname().unwrap_or(""), chan),
|
||||
PART(ref chan, _) => self.handle_part(msg.source_nickname().unwrap_or(""), chan),
|
||||
|
|
|
@ -11,6 +11,8 @@ extern crate error_chain;
|
|||
extern crate encoding;
|
||||
#[macro_use]
|
||||
extern crate futures;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate native_tls;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
|
|
Loading…
Reference in a new issue