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

Enable asynchronous logging #153

Open
davidiw opened this issue Mar 5, 2020 · 1 comment
Open

Enable asynchronous logging #153

davidiw opened this issue Mar 5, 2020 · 1 comment

Comments

@davidiw
Copy link

davidiw commented Mar 5, 2020

Have you any plans to enable asynchronous logging via mpsc channels and a std thread? We're exploring that in Libra and I'd love to push that upstream if possible.

@KodrAus
Copy link
Collaborator

KodrAus commented Jul 1, 2020

Hey @davidiw 👋

Since env_logger is exclusively targeted at outputting to an attached stream that needs to be locked anyways I haven't really thought about asynchronous logging. I think the best approach might be to add some methods to env_logger::Logger that let you format a log::Record into something like this:

// Send + Sync
pub struct FormattedRecord {
    value: Vec<u8>,
    output: Stream,
}

impl FormattedRecord {
    pub fn output(&self) -> io::Result<()> {
        // write to the appropriate stream
    }
}

so that you could ask env_logger to format up a record for you into something you could add to a channel and then write to the output stream later.

What do you think?

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

3 participants