Skip to content

Commit

Permalink
refactor(instrument): explicit opt in trace level
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Feb 25, 2022
1 parent da1e8e3 commit 0686d07
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crates/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct JsCompiler {
impl JsCompiler {
#[napi(constructor)]
#[allow(clippy::new_without_default)]
#[tracing::instrument(skip_all)]
#[tracing::instrument(level = "trace", skip_all)]
pub fn new() -> Self {
Self {
_compiler: COMPILER.clone(),
Expand Down
8 changes: 4 additions & 4 deletions crates/node/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Task for TransformTask {
type JsValue = TransformOutput;
type Output = TransformOutput;

#[instrument(skip_all)]
#[instrument(level = "trace", skip_all)]
fn compute(&mut self) -> napi::Result<Self::Output> {
let mut options: Options = serde_json::from_slice(self.options.as_ref())?;
if !options.filename.is_empty() {
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Task for TransformTask {
}

#[napi]
#[instrument(skip_all)]
#[instrument(level = "trace", skip_all)]
pub fn transform(
src: String,
is_module: bool,
Expand All @@ -120,7 +120,7 @@ pub fn transform(
}

#[napi]
#[instrument(skip_all)]
#[instrument(level = "trace", skip_all)]
pub fn transform_sync(s: String, is_module: bool, opts: Buffer) -> napi::Result<TransformOutput> {
crate::util::init_trace_once(false, None)?;

Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn transform_sync(s: String, is_module: bool, opts: Buffer) -> napi::Result<
}

#[napi]
#[instrument(skip_all)]
#[instrument(level = "trace", skip_all)]
pub fn transform_file(
src: String,
_is_module: bool,
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn init_trace_once(
Ok(())
}

#[instrument(skip_all)]
#[instrument(level = "trace", skip_all)]
pub fn try_with<F, Ret>(cm: Lrc<SourceMap>, skip_filename: bool, op: F) -> Result<Ret, Error>
where
F: FnOnce(&Handler) -> Result<Ret, Error>,
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl Write for LockedWriter {

/// Try operation with a [Handler] and prints the errors as a [String] wrapped
/// by [Err].
#[instrument(skip_all)]
#[instrument(level = "trace", skip_all)]
pub fn try_with_handler<F, Ret>(
cm: Lrc<SourceMap>,
skip_filename: bool,
Expand Down
14 changes: 7 additions & 7 deletions crates/swc_ecma_transforms_compat/src/es2015/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, InjectVars, VisitMut,
/// };
/// console.log(bob.printFriends());
/// ```
#[tracing::instrument(skip_all)]
#[tracing::instrument(level = "trace", skip_all)]
pub fn arrow() -> impl Fold + VisitMut + InjectVars {
as_folder(Arrow::default())
}
Expand All @@ -70,7 +70,7 @@ struct Arrow {
impl VisitMut for Arrow {
noop_visit_mut_type!();

#[tracing::instrument(skip_all)]
#[tracing::instrument(level = "trace", skip_all)]
fn visit_mut_class(&mut self, c: &mut Class) {
if c.super_class.is_some() {
self.in_subclass = true;
Expand All @@ -79,7 +79,7 @@ impl VisitMut for Arrow {
self.in_subclass = false;
}

#[tracing::instrument(skip_all)]
#[tracing::instrument(level = "trace", skip_all)]
fn visit_mut_constructor(&mut self, c: &mut Constructor) {
c.params.visit_mut_children_with(self);

Expand Down Expand Up @@ -108,7 +108,7 @@ impl VisitMut for Arrow {
}
}

#[tracing::instrument(skip_all)]
#[tracing::instrument(level = "trace", skip_all)]
fn visit_mut_expr(&mut self, expr: &mut Expr) {
match expr {
Expr::Arrow(ArrowExpr {
Expand Down Expand Up @@ -167,12 +167,12 @@ impl VisitMut for Arrow {
}
}

#[tracing::instrument(skip_all)]
#[tracing::instrument(level = "trace", skip_all)]
fn visit_mut_function(&mut self, f: &mut Function) {
f.visit_mut_children_with(self);
}

#[tracing::instrument(skip_all)]
#[tracing::instrument(level = "trace", skip_all)]
fn visit_mut_module_items(&mut self, stmts: &mut Vec<ModuleItem>) {
stmts.visit_mut_children_with(self);

Expand All @@ -183,7 +183,7 @@ impl VisitMut for Arrow {
}
}

#[tracing::instrument(skip_all)]
#[tracing::instrument(level = "trace", skip_all)]
fn visit_mut_stmts(&mut self, stmts: &mut Vec<Stmt>) {
let old_rep = self.hoister.take();

Expand Down

0 comments on commit 0686d07

Please sign in to comment.