offer function-level control over tracing (#5194)
* wiggle: fix compilation with async functions when tracing is off Fixes #5202 * switch tracing config from a boolean to a struct This will enable more complex tracing rules in the future * rename AsyncConfField to FunctionField It is going to be reused for cases other than just async functions * add support for disabling tracing per-function This adds a `disable_for` syntax after the `tracing` boolean. For example: ``` wiggle::from_witx!( tracing: true disable_for { module1::foo, module2::{bar, baz}, } ) ```
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::config::{AsyncConf, ErrorConf};
|
||||
use crate::config::{AsyncConf, ErrorConf, TracingConf};
|
||||
use anyhow::{anyhow, Error};
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
@@ -15,7 +15,7 @@ pub struct CodegenSettings {
|
||||
// Disabling this feature makes it possible to remove all of the tracing
|
||||
// code emitted in the Wiggle-generated code; this can be helpful while
|
||||
// inspecting the code (e.g., with `cargo expand`).
|
||||
pub tracing: bool,
|
||||
pub tracing: TracingConf,
|
||||
}
|
||||
impl CodegenSettings {
|
||||
pub fn new(
|
||||
@@ -23,14 +23,14 @@ impl CodegenSettings {
|
||||
async_: &AsyncConf,
|
||||
doc: &Document,
|
||||
wasmtime: bool,
|
||||
tracing: bool,
|
||||
tracing: &TracingConf,
|
||||
) -> Result<Self, Error> {
|
||||
let errors = ErrorTransform::new(error_conf, doc)?;
|
||||
Ok(Self {
|
||||
errors,
|
||||
async_: async_.clone(),
|
||||
wasmtime,
|
||||
tracing,
|
||||
tracing: tracing.clone(),
|
||||
})
|
||||
}
|
||||
pub fn get_async(&self, module: &Module, func: &InterfaceFunc) -> Asyncness {
|
||||
|
||||
Reference in New Issue
Block a user