Skip to content

Commit

Permalink
feat: add tracing_subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Jan 14, 2025
1 parent 95cf333 commit b0b260f
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
54 changes: 51 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sqlx = { version = "0.8.3", default-features = false, features = [
"runtime-tokio-rustls",
] }
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
version = "3.0.0"

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mod used_in_bin {
use shuttle_serenity as _;
use shuttle_shared_db as _;
use tracing_subscriber as _;
}

use tracing::{info, instrument};
Expand Down
16 changes: 14 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use std::sync::Arc;

use anyhow::Context as _;
use bazooka_bot::{commands_list, get_secret_discord_token, Data, SharedConfig, StartupConfig};
use poise::serenity_prelude::{ClientBuilder, GatewayIntents};
use secrecy::ExposeSecret;
use shuttle_runtime::SecretStore;
use shuttle_serenity::ShuttleSerenity;
use std::sync::Arc;
use tracing::{error, info, warn};
use tracing_subscriber::{
fmt::{self, format::FmtSpan},
prelude::*,
EnvFilter,
};
use version::version;

#[shuttle_runtime::main]
Expand All @@ -17,6 +21,14 @@ async fn main(
)]
db_pool: sqlx::PgPool,
) -> ShuttleSerenity {
tracing_subscriber::registry()
.with(fmt::layer().with_span_events(FmtSpan::ACTIVE))
.with(
EnvFilter::try_from_default_env()
.unwrap_or_else(|_| EnvFilter::new("zbus=warn,serenity=warn,info")),
)
.init();

info!("Bot version is {}", version::version!());

sqlx::migrate!("./migrations")
Expand Down

0 comments on commit b0b260f

Please sign in to comment.