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

Log to file #52

Open
sleeyax opened this issue Jan 19, 2023 · 2 comments
Open

Log to file #52

sleeyax opened this issue Jan 19, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@sleeyax
Copy link

sleeyax commented Jan 19, 2023

Is it possible to write logs to a file? It would be nice if there was a way to both log to console/terminal and write to a .txt file to view output logs of long-running operations at a later point in time.

@sleeyax sleeyax added the enhancement New feature or request label Jan 19, 2023
@0x20F
Copy link
Owner

0x20F commented Jan 23, 2023

Hi! Thank you for the issue!

It's not possible at the moment.
However it shouldn't be that hard to implement given the fact that the formatter already has a flag to exclude colors from the generated logs if needed. Those could then be piped out into a file if, say, the "to-file" feature is enabled or something similar.

Suggestion

I will unfortunately not be able to sit with this for a few weeks, however, if you'd like to give it a try I would suggest you start by looking at the stdout method of the logger in src/logger/mod.rs.

If the feature is enabled, you would run format_string (in src/formatter/mod.rs) with the second parameter as false in order to remove all the color keys from the string and dump the line into a file of your choosing.

@XARP616
Copy link

XARP616 commented Apr 4, 2023

Maybe you can try simplelog, which has different types of loggers (see readme, TermLogger, WriteLogger) and does implement paris as a feature for beatiful ouput.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants