From c0538a2a50b0921e4ecfc15410af6d8fcd71bbe7 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 28 Apr 2021 23:22:51 -0400 Subject: [PATCH] use logger --- src/main.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index f12acbbe56..4e93da8edf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,14 +8,11 @@ use twitchchat::{ UserConfig, }; -use anyhow::{Context, Error}; use anyhow::anyhow; - +use anyhow::{Context, Error}; +use log::{info, warn}; use redis::aio::Connection; use redis::{AsyncCommands, RedisResult}; - -pub type AnyhowResult = anyhow::Result; - use std::thread; use std::time::Duration; @@ -28,6 +25,8 @@ use crate::twitch_client::TwitchClient; use crate::secrets::Secrets; use crate::redis_client::RedisClient; +pub type AnyhowResult = anyhow::Result; + const ENV_PUBLISH_TOPIC : &'static str = "PUBLISH_TOPIC"; const ENV_PUBLISH_TOPIC_DEFAULT : &'static str = "twitch"; @@ -52,13 +51,13 @@ async fn main() -> anyhow::Result<()> { loop { match twitch_client.main_loop().await { Ok(_) => { - println!("Early exit? Restarting..."); + warn!("Twitch early exit? Restarting..."); thread::sleep(Duration::from_secs(5)); }, Err(e) => { - println!("There was an error: {:?}", e); + warn!("There was an error with Twitch: {:?}", e); thread::sleep(Duration::from_secs(5)); - println!("Restarting client..."); + warn!("Restarting Twitch client..."); } } }