Skip to content

Commit

Permalink
feat(examples): enable tracing on embed (#105)
Browse files Browse the repository at this point in the history
* feat(examples): enable tracing on embed

* fix(ci): docs
  • Loading branch information
fundon authored Dec 5, 2023
1 parent 2a7836e commit 4a771be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
name: Doc
runs-on: ubuntu-latest
env:
RUSTFLAGS: --cfg hyper_unstable_tracing
RUSTDOCFLAGS: -Dwarnings --cfg docsrs
steps:
- uses: actions/checkout@v4
Expand Down
11 changes: 11 additions & 0 deletions examples/static-files/embed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ version = "0.1.0"
edition.workspace = true
publish = false

[features]
tracing = [
"dep:hyper",
"dep:tracing",
"dep:tracing-subscriber"
]

[dependencies]
viz = { workspace = true, features = ["embed"] }

tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
rust-embed.workspace = true

hyper = { workspace = true, features = ["tracing"], optional = true }
tracing = { workspace = true, optional = true }
tracing-subscriber = { workspace = true, features = ["env-filter"], optional = true }
3 changes: 3 additions & 0 deletions examples/static-files/embed/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ struct Asset;

#[tokio::main]
async fn main() -> Result<()> {
#[cfg(feature = "tracing")]
tracing_subscriber::fmt::init();

let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
let listener = TcpListener::bind(addr).await?;
println!("listening on http://{addr}");
Expand Down

0 comments on commit 4a771be

Please sign in to comment.