Skip to content

Commit

Permalink
wasmtime-cli: add tracing output on WASMTIME_LOG (bytecodealliance#…
Browse files Browse the repository at this point in the history
…7239)

* wasmtime cli: install tracing-subscriber, listen to WASMTIME_LOG, log to stderr

* enable tracing colors

* audit supply chain for tracing subscriber
  • Loading branch information
Pat Hickey authored Oct 13, 2023
1 parent f0dacd5 commit f952ff2
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 23 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ wasmtime-runtime = { workspace = true }
clap = { workspace = true, features = ["color", "suggestions", "derive"] }
anyhow = { workspace = true }
target-lexicon = { workspace = true }
tracing-subscriber = { workspace = true }
once_cell = { workspace = true }
listenfd = "1.0.0"
wat = { workspace = true }
Expand Down Expand Up @@ -263,7 +264,7 @@ indexmap = "2.0.0"
pretty_env_logger = "0.5.0"
syn = "2.0.25"
test-log = { version = "0.2", default-features = false, features = ["trace"] }
tracing-subscriber = { version = "0.3.1", default-features = false, features = ['fmt', 'env-filter'] }
tracing-subscriber = { version = "0.3.1", default-features = false, features = ['fmt', 'env-filter', 'ansi'] }
url = "2.3.1"

[features]
Expand Down
10 changes: 10 additions & 0 deletions src/bin/wasmtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ impl Wasmtime {
}

fn main() -> Result<()> {
use std::io::IsTerminal;
use tracing_subscriber::{EnvFilter, FmtSubscriber};

let mut b = FmtSubscriber::builder()
.with_writer(std::io::stderr)
.with_env_filter(EnvFilter::from_env("WASMTIME_LOG"));
if std::io::stderr().is_terminal() {
b = b.with_ansi(true);
}
b.init();
Wasmtime::parse().execute()
}

Expand Down
29 changes: 29 additions & 0 deletions supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,12 @@ criteria = "safe-to-deploy"
version = "0.2.11"
notes = "build is only looking for environment variables to set cfg. only two minor uses of unsafe,on macos, with ffi bindings to digest primitives and libc atexit. otherwise, this is an abstraction over three very complex systems (schannel, security-framework, and openssl) which may end up having subtle differences, but none of those are apparent from the implementation of this crate"

[[audits.nu-ansi-term]]
who = "Pat Hickey <phickey@fastly.com>"
criteria = "safe-to-deploy"
version = "0.46.0"
notes = "one use of unsafe to call windows specific api to get console handle."

[[audits.object]]
who = "Chris Fallin <chris@cfallin.org>"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -1707,6 +1713,12 @@ who = "Andrew Brown <andrew.brown@intel.com>"
criteria = "safe-to-deploy"
delta = "0.4.2 -> 0.5.0"

[[audits.overload]]
who = "Pat Hickey <phickey@fastly.com>"
criteria = "safe-to-deploy"
version = "0.1.1"
notes = "small crate, only defines macro-rules!, nicely documented as well"

[[audits.peeking_take_while]]
who = "Nick Fitzgerald <fitzgen@gmail.com>"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -1904,6 +1916,12 @@ criteria = "safe-to-deploy"
delta = "0.9.9 -> 0.10.2"
notes = "This upgrade is mostly a code refactor, as far as I can tell. No new uses of unsafe nor any new ambient capabilities usage."

[[audits.sharded-slab]]
who = "Pat Hickey <phickey@fastly.com>"
criteria = "safe-to-deploy"
version = "0.1.4"
notes = "I always really enjoy reading eliza's code, she left perfect comments at every use of unsafe."

[[audits.signal-hook-registry]]
who = "Pat Hickey <phickey@fastly.com>"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -2017,6 +2035,12 @@ who = "Pat Hickey <phickey@fastly.com>"
criteria = "safe-to-deploy"
version = "0.2.11"

[[audits.thread_local]]
who = "Pat Hickey <phickey@fastly.com>"
criteria = "safe-to-deploy"
version = "1.1.4"
notes = "uses unsafe to implement thread local storage of objects"

[[audits.tinyvec]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -2096,6 +2120,11 @@ This is a relatively minor set of releases with minor refactorings and bug
fixes. Nothing fundamental was added in these changes.
"""

[[audits.tracing-subscriber]]
who = "Pat Hickey <phickey@fastly.com>"
criteria = "safe-to-deploy"
version = "0.3.17"

[[audits.tracing-subscriber]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
Expand Down
15 changes: 0 additions & 15 deletions supply-chain/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ audit-as-crates-io = true
[policy.wasmtime-wit-bindgen]
audit-as-crates-io = true

[policy.wasmtime-wmemcheck]
audit-as-crates-io = true

[policy.wiggle]
audit-as-crates-io = true

Expand Down Expand Up @@ -527,10 +524,6 @@ notes = "contains assembly language and object file implementations of crypto pr
version = "0.3.0"
criteria = "safe-to-deploy"

[[exemptions.sharded-slab]]
version = "0.1.4"
criteria = "safe-to-run"

[[exemptions.shellexpand]]
version = "2.1.0"
criteria = "safe-to-deploy"
Expand Down Expand Up @@ -579,10 +572,6 @@ criteria = "safe-to-deploy"
version = "0.1.17"
criteria = "safe-to-deploy"

[[exemptions.thread_local]]
version = "1.1.4"
criteria = "safe-to-run"

[[exemptions.tinytemplate]]
version = "1.2.1"
criteria = "safe-to-run"
Expand All @@ -608,10 +597,6 @@ criteria = "safe-to-deploy"
version = "0.1.28"
criteria = "safe-to-deploy"

[[exemptions.tracing-subscriber]]
version = "0.3.11"
criteria = "safe-to-run"

[[exemptions.typenum]]
version = "1.15.0"
criteria = "safe-to-deploy"
Expand Down
6 changes: 0 additions & 6 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1010,12 +1010,6 @@ when = "2023-09-20"
user-id = 73222
user-login = "wasmtime-publish"

[[publisher.wasmtime-wmemcheck]]
version = "13.0.0"
when = "2023-09-20"
user-id = 73222
user-login = "wasmtime-publish"

[[publisher.wast]]
version = "65.0.2"
when = "2023-09-26"
Expand Down
6 changes: 5 additions & 1 deletion tests/all/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn get_wasmtime_command() -> Result<Command> {
// If we're running tests with a "runner" then we might be doing something
// like cross-emulation, so spin up the emulator rather than the tests
// itself, which may not be natively executable.
let cmd = if let Some((_, runner)) = runner {
let mut cmd = if let Some((_, runner)) = runner {
let mut parts = runner.split_whitespace();
let mut cmd = Command::new(parts.next().unwrap());
for arg in parts {
Expand All @@ -44,6 +44,10 @@ pub fn get_wasmtime_command() -> Result<Command> {
Command::new(&me)
};

if let Ok(val) = std::env::var("WASMTIME_LOG") {
cmd.env("WASMTIME_LOG", val);
}

Ok(cmd)
}

Expand Down

0 comments on commit f952ff2

Please sign in to comment.