paris icon indicating copy to clipboard operation
paris copied to clipboard

Log to file

Open sleeyax opened this issue 2 years ago • 2 comments

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 avatar Jan 19 '23 21:01 sleeyax

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.

0x20F avatar Jan 23 '23 10:01 0x20F

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.

XARP616 avatar Apr 04 '23 13:04 XARP616