Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support tokio-console #40

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ lld = true
# [target.x86_64-unknown-linux-gnu]
# rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"]

# Enable UUID Unstable Features
# https://docs.rs/uuid/1.4.0/uuid/index.html#unstable-features
[target.'cfg(all())']
rustflags = ["--cfg", "uuid_unstable"]
rustflags = [
# UUID Unstable for Uuid::now_v7()
# https://docs.rs/uuid/1.4.0/uuid/index.html#unstable-features
"--cfg",
"uuid_unstable",
# Tokio Unstable for `console` feature
# https://github.com/tokio-rs/console#instrumenting-your-program
"--cfg",
"tokio_unstable",
]

# x86_64-v3 (Intel Haswell / AMD Excavator and above)
# https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels
Expand Down
165 changes: 159 additions & 6 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ opt-level = "z"
panic = "abort"
strip = "symbols"

[features]
default = ["tokio-console"]
tokio-console = ["dep:console-subscriber", "tokio/tracing"]

[workspace]
members = [
".",
Expand Down Expand Up @@ -134,3 +138,6 @@ tokio-graceful-shutdown = { workspace = true }
tracing = { workspace = true }
tracing-error = { workspace = true }
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }

# optional-dependencies
console-subscriber = { version = "0.2", optional = true }
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ use tracing_subscriber::prelude::*;
async fn main() -> Result<(), AppError> {
setup_panic!(metadata!().homepage("https://github.com/importantimport/hatsu/issues"));

tracing_subscriber::registry()
let registry = tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_error::ErrorLayer::default())
.init();
.with(tracing_error::ErrorLayer::default());

#[cfg(feature = "tokio-console")]
let registry = registry.with(console_subscriber::spawn());

registry.init();

tracing::info!("loading environment variables");
if dotenvy::dotenv().is_err() {
Expand Down
Loading