Skip to content

How to not print fields on one layer only? #3396

@frederikhors

Description

@frederikhors

I'm using:

#[tracing::instrument(skip(self, db, zero, second))]
pub async fn player(
    &self,
    db: Option<&Db>,
    zero: &Zero,
    other: &mut Other,
    second: Option<&Second>,
    third: Third,
    four: Option<Four>,
) -> Result<Player> {
    // code
}

Everything works.

Now I need to NOT print fields in one of the layer I'm building like this:

let dev_layer = Layer::default()
    .with_writer(writer)
    .pretty()
    .with_file(false)
    .with_span_events(FmtSpan::CLOSE);
    .with_filter(/*...*/);

The only idea I have is to use:

dev_layer.map_fmt_fields(|_| debug_fn(|_, _, _| Ok(())))

But maybe there is a better way. Is there?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions