greaseweazle icon indicating copy to clipboard operation
greaseweazle copied to clipboard

Proper logging subsystem which can redirect to file

Open raffaeler opened this issue 3 years ago • 7 comments

I prefer to save the log on a file to remember which tracks presented the problem. I tried to redirect gw stdout to a file (> mylog.txt) but it doesn't get captured. Also, redirecting is not practical on Windows because I could not see the progress.

The suggestion is to add a parameter that saves the whole log (same of the console) to a file whose name is the same of the image with the .log or .txt extension.

raffaeler avatar Jan 26 '22 10:01 raffaeler

Logging goes to stderr.

In Powershell at least you should be able to do something shell-y, like: gw .... 2>&1 | tee mylog.txt.

Proper logging would be nicer.

keirf avatar Jan 26 '22 11:01 keirf

Ah ok, I didn't expect non-errors being sent to stderr, in fact PS shows everything in red

There could possibly be two files, one for the info log and the other for the error log. Personally, I would like to only save the one with errors so that I can examine later the results of the reads.

raffaeler avatar Jan 26 '22 12:01 raffaeler

I think a logging system would allow priority levels to be applied and errors could be flagged as such in the one single log file, for easy filtering. Use of stderr is not super unusual, it leaves stdout free for piping disk images (not actually supported now, but may be in future), and it had a benefit that I could turn off buffering forthose who are piping stderr (GUI wrappers).

keirf avatar Jan 26 '22 16:01 keirf

Got it, it makes sense. My scenario is simple: say you have a lot of disks to read: you process one after the other disregarding the console output. At the end of this batch job, you just take a look at the logs containing errors and validate whether the error may have affected or not the files.

It would be super-useful to know which files are affected from the errors. You already have the filesystem from the --format parameter. Is this complicated?

raffaeler avatar Jan 26 '22 17:01 raffaeler

I don't do filesystem analysis in Greaseweazle currently. Adding FAT12 wouldn't be hard I suppose.

keirf avatar Jan 26 '22 17:01 keirf

I don't do filesystem analysis in Greaseweazle currently. Adding FAT12 wouldn't be hard I suppose.

If you want to let somebody do it externally, it would be very useful to log the info in a structured way (json, csv, xml, ...) so that I can load the info and the image from my code and provide a feedback on the files being subject to the corruption.

raffaeler avatar Jan 26 '22 17:01 raffaeler

+1 On logging the result

korpx avatar Sep 19 '22 20:09 korpx