daboross / fern

Simple, efficient logging for Rust
MIT License
846 stars 51 forks source link

Reading from Box not possible since fern::Output::writer consumes it? #130

Closed unixb0y closed 9 months ago

unixb0y commented 9 months ago

What I'm trying to do is logging into a Vec, which I can then process with my own code. I use Ratatui for my GUI and therefore I'd like an in-memory representation of my logs to show in one location.

I've been trying to get that to work starting from this example from the docs: https://docs.rs/fern/latest/fern/struct.Output.html#method.writer

However, fern::Output::writer consumes the Box, therefore I can't read back from it. Am I doing something wrong here? Is there a way to solve this?

piegamesde commented 9 months ago

Yes, that is by design. You cannot access the writer itself while fern is (potentially) writing to it. You may use one of the following solutions instead:

unixb0y commented 9 months ago

Alright, thanks!