Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to filter by &Record #81

Open
broccolihighkicks opened this issue Jul 6, 2021 · 1 comment
Open

How to filter by &Record #81

broccolihighkicks opened this issue Jul 6, 2021 · 1 comment

Comments

@broccolihighkicks
Copy link

Is it possible to filter based on the data in a &Record?

The normal .filter() fn only provides &log::Metadata which only contains a level and a str target.

Record contains information about the file path which I want to use to group by "my-app-workspace", "my-other-local-crates" and "cargo dep".

fern::Dispatch::new()
    .format(move |out, message, record| {
        if !include_in_output(record) {
            // Issue: Returning from `format` seems to default to printing `message`
            return;
        }

        out.finish(format_args!("{} {}", "a", "b"));
    });

Thanks

@daboross
Copy link
Owner

daboross commented Jul 8, 2021

Right - there isn't, but this would definitely be useful to add. I'm not 100% sure why these aren't included in Metadata, since file and module_path do seem like metadata, but they aren't.

I don't think it will be possible to add this within the current format method, so I may need to add a new method and make the transfer over only on the next breaking release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants