Switched to tracing for logging
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use std::fmt::{Debug, Display};
|
||||
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
#[error("No user info found")]
|
||||
@ -20,12 +21,20 @@ pub enum InvalidCommand {
|
||||
UnknownLocale,
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn init_logger() {
|
||||
tracing_subscriber::registry()
|
||||
.with(fmt::layer().pretty())
|
||||
.with(EnvFilter::from_default_env())
|
||||
.init();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn handle_error<T>(error: T)
|
||||
where
|
||||
T: Debug + Display,
|
||||
{
|
||||
log::error!("{error}\n{error:?}");
|
||||
tracing::error!(error_debug = ?error, error_message = %error);
|
||||
}
|
||||
|
||||
pub struct ErrorHandler;
|
||||
|
@ -88,7 +88,7 @@ fn get_dispatcher(
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let _ = dotenv();
|
||||
pretty_env_logger::init_timed();
|
||||
errors::init_logger();
|
||||
|
||||
locales::LocaleStore::init();
|
||||
|
||||
|
Reference in New Issue
Block a user