Add custom tracing_subscriber

This commit is contained in:
Aadi Desai 2023-09-29 01:48:12 +01:00
parent f8eee82843
commit f3929a7885
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
3 changed files with 17 additions and 25 deletions

26
Cargo.lock generated
View file

@ -287,17 +287,6 @@ dependencies = [
"windows-targets",
]
[[package]]
name = "colored"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6"
dependencies = [
"is-terminal",
"lazy_static",
"windows-sys",
]
[[package]]
name = "comfy-table"
version = "6.2.0"
@ -1106,17 +1095,6 @@ version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6"
[[package]]
name = "is-terminal"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
"rustix",
"windows-sys",
]
[[package]]
name = "itertools"
version = "0.10.5"
@ -1313,6 +1291,7 @@ dependencies = [
"sqlx",
"tokio",
"tracing",
"tracing-subscriber",
"url",
]
@ -2363,7 +2342,6 @@ dependencies = [
"anyhow",
"async-trait",
"chrono",
"colored",
"prost-types",
"serde",
"serde_json",
@ -2377,7 +2355,6 @@ dependencies = [
"tokio-stream",
"tonic",
"tower",
"tracing-subscriber",
]
[[package]]
@ -3162,6 +3139,7 @@ dependencies = [
"sharded-slab",
"smallvec",
"thread_local",
"time",
"tracing",
"tracing-core",
"tracing-log",

View file

@ -17,7 +17,7 @@ indoc = "2.0.4"
poise = "0.5.6"
reqwest = { version = "0.11.20", features = ["json"] }
serde = { version = "1.0.188", features = ["derive"] }
shuttle-runtime = "0.27.0"
shuttle-runtime = { version = "0.27.0", default-features = false }
shuttle-secrets = "0.27.0"
shuttle-shared-db = { version = "0.27.0", features = ["postgres"] }
sqlx = { version = "0.7.2", features = [
@ -27,4 +27,5 @@ sqlx = { version = "0.7.2", features = [
] }
tokio = "1.32.0"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["time"] }
url = "2.4.1"

View file

@ -54,6 +54,19 @@ async fn poise(
#[shuttle_secrets::Secrets] secret_store: shuttle_secrets::SecretStore,
#[shuttle_shared_db::Postgres] pool: sqlx::PgPool,
) -> Result<service::NanoBot, shuttle_runtime::Error> {
// Set Up Tracing Subscriber
use tracing_subscriber as ts;
use ts::prelude::*;
ts::registry()
.with(ts::fmt::layer().without_time())
.with(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
tracing_subscriber::EnvFilter::new("info,nano=info,shuttle=trace,serenity=warn")
}),
)
.init();
tracing::info!("Tracing Subscriber Set Up");
// Run SQLx Migrations
sqlx::migrate!()
.run(&pool)