Use env var to configure logging

This commit is contained in:
Alex Page 2023-03-18 01:06:50 -04:00
parent 8a56fcf126
commit 22eba91a17
2 changed files with 9 additions and 2 deletions

View file

@ -8,12 +8,15 @@ anyhow = "1.0.69"
parking_lot = "0.12.1"
poise = "0.5.2"
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
tracing-futures = "0.2.5"
openai = "1.0.0-alpha.6"
rand = "0.8.5"
thiserror = "1.0.39"
[dependencies.tracing-subscriber]
version = "0.3.16"
features = ["fmt", "env-filter", "std"]
[dependencies.songbird]
version = "0.3.1"
features = ["yt-dlp"]

View file

@ -5,6 +5,7 @@ mod personality;
mod queue;
use commands::*;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use std::{env, sync::Arc};
@ -42,7 +43,10 @@ async fn register(ctx: CommandContext<'_>) -> Result<(), Error> {
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt().init();
tracing_subscriber::registry()
.with(fmt::layer())
.with(EnvFilter::from_default_env())
.init();
let token =
env::var("DISCORD_TOKEN").expect("Expected a bot token in the environment: DISCORD_TOKEN");