-
Notifications
You must be signed in to change notification settings - Fork 130
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
Logging to a file? #178
Comments
Sure, sounds like a simple enough addition. @sirwindfield wdyt? One thing to note is that this can't be done in a backwards-compatible manner, because |
If we decide to do this, we might want to copy what simplelog does and accept anything that is writable. |
Also, |
Right. Could potentially be made non-exhaustive with the next version. |
I’ve previously punted on supporting file logging, because it’s a bit of a can of worms. You can’t really just pipe records into a file, you end up needing to have custom file patterns, rolling files with configurable sizes, deal with transient IO errors and slow writes. It’s definitely possible, and has been done plenty before, but it always ends up being a whole stack of its own to maintain 🙂 |
@KodrAus What about adding a note that we don't do any of this? I think just piping records into a file would work well for short-lived programs, even if it quickly breaks down for daemons or server applications. |
Maybe we could design it to indirectly support files, instead of baking it in? So it might look something like: enum Target {
Pipe(Box<dyn Write>),
..
} which we then wrap in a |
Yeah, I wouldn't want to bake in file either, that's why I mentioned how |
Ye, I wouldn't want to just support a File object alone. We should definitely abstract it somehow away. Just to be sure here, |
That's exactly what it does. |
Hi! I tried to work out logging to a file based on custom_target example, but I could not. Do you mind telling me my mistakes, or adding an example on how to do this? |
Thank you very much! |
Would it make sense to add a Target variant for logging to a file? It doesn't make sense to print to stdout or stderr in TUI applications as that breaks the TUI, and having to ask users to redirect stderr to a file is inconvenient.
Context: osa1/tiny#238
The text was updated successfully, but these errors were encountered: