Skip to content

Commit

Permalink
fix: Fix WASM logs not showing up. (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Sep 29, 2023
1 parent effe1f6 commit 6306755
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
- Added a `pin-latest` setting to `~/.proto/config.toml` that'll automatically pin tools when they're being installed with the "latest" version.
- Updated `proto install` to auto-clean stale plugins after a successful installation.

#### ⚙️ Internal

- Added `PROTO_WASM_LOG` environment variable to toggle the logging of messages from Extism and WASM plugins. Useful for debugging.

## 0.18.5

#### ⚙️ Internal
Expand Down
2 changes: 2 additions & 0 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ async fn main() -> MainResult {
LevelFilter::INFO
},
filter_modules: string_vec!["proto", "starbase", "warpgate"],
// This swallows logs from extism when enabled
intercept_log: env::var("PROTO_WASM_LOG").is_err(),
log_env: "STARBASE_LOG".into(),
test_env: "PROTO_TEST".into(),
..TracingOptions::default()
Expand Down
5 changes: 0 additions & 5 deletions crates/core/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ use tracing::trace;

pub static ENV_VAR: Lazy<Regex> = Lazy::new(|| Regex::new(r"\$([A-Z0-9_]+)").unwrap());

#[deprecated = "Use `get_proto_home` instead."]
pub fn get_root() -> miette::Result<PathBuf> {
get_proto_home()
}

pub fn get_proto_home() -> miette::Result<PathBuf> {
if let Ok(root) = env::var("PROTO_HOME") {
return Ok(root.into());
Expand Down
8 changes: 5 additions & 3 deletions crates/core/src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ impl Tool {
on_uninstalled_global: Emitter::new(),
};

#[cfg(debug_assertions)]
{
extism::set_log_file(proto.cwd.join("wasm-debug.log"), None);
if let Ok(level) = env::var("PROTO_WASM_LOG") {
extism::set_log_file(
proto.cwd.join("wasm-debug.log"),
std::str::FromStr::from_str(&level).ok(),
);
}

debug!(
Expand Down

0 comments on commit 6306755

Please sign in to comment.