wvanbergen/request-log-analyzer — Issue #107: Output to STDOUT injects cruft when using shell output redirection
Author: bradland
Created: 2012-02-16 21:59:04+00:00
State: open

There are a couple of places where outputting to the STDOUT necessitates the use of the '--silent' option if you want to avoid cruft in your output files (when using shell redirection). Changing to STDERR would result in the user still seeing the messages, but would be omitted from the redirected output. Win-win! :)

1) [lib/request_log_analyzer/controller.rb:265](https://github.com/wvanbergen/request-log-analyzer/blob/master/lib/request_log_analyzer/controller.rb#L265) - Third argument to `ProgressBar.new` is set to `STDOUT`, but based on [lib/cli/progressbar.rb:15](https://github.com/wvanbergen/request-log-analyzer/blob/master/lib/cli/progressbar.rb#L15) we can see that someone thought `STDERR` might not be a bad idea. I altered my controller.rb:265 to use STDERR as the third argument and it works great. No more cruft in the redirected output, and I can still see progress in the console.

2) [bin/request-log-analyzer:122-124](bin/request-log-analyzer#L122) - The attribution tag lines are written using `puts`, which defaults to `STDOUT`. When using redirection, this is prepended to the beginning of the output, which isn't so bad for text, but results in plaintext outside the html for HTML output. I altered these lines to use `STDERR.puts`, which eliminated the cruft from the file, but still outputs to the console so we don't forget who to thank :)

After investigating this a bit, I noticed the '--file' option, which negates the need to use redirection at all, but I thought that given the simplicity of these two changes, in exchange for a more "Unixy" behavior, it might be worthwhile.