fastly/Viceroy

viceroy_lib::ExecuteCtx always logs

GeeWee opened this issue · 0 comments

When creating an ExecuteCtx like this, I am still receiving console output.

let path = Path::new("../target/wasm32-wasi/release/edge-api.wasi.wasm");
    if (!path.exists()) {
        panic!("Unable to find wasm file at path {path:?} - potentially the wasm binary has not been built");
    }
    viceroy_lib::ExecuteCtx::new(&path)
        .unwrap()
        .with_log_stderr(false)
        .with_log_stdout(false) // no need to log all of stdout by default

    // then perform some request using handle_request

I have a main function that looks like this:

#[fastly::main]
fn main(mut req: Request) -> Result<Response, Error> {
    println!("hello");
    eprintln!("error");
    // set up of fastly logging infrastructure here

    log::warn!("log!");
    tracing::warn!("tracing!");
   // actual request handling here
}

And I get the following output, even when tests pass:

running 1 test
hello
error
logs :: log!
  2022-08-30T12:32:38.601161Z  WARN edge_api: tracing!
    at edge-api/src/main.rs:33
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 243 filtered out; finished in 1.96s

I would expect that either:

  • with_log_stderr and stdout set to false, it would never log anything.
  • Or even better, if they were set to true, it would only log for failed tests. Currently it seems like cargo test does not capture the output like normal.