papertrail / papertrail-cli

Command-line client for Papertrail hosted syslog & app log management service
http://papertrailapp.com/
MIT License
426 stars 46 forks source link

Exit when stdout closed #74

Closed lmarburger closed 8 years ago

lmarburger commented 8 years ago

When piping papertrail to another program, the downstream program can close the pipe and we need to exit cleanly. It seems this can be resolved either by trapping PIPE or rescuing Errno::EPIPE (likely in Papertrail::Cli#run). Opted for the former but I have no preference.

closes #73

lmarburger commented 8 years ago

Might as well just rescue Errno::EPIPE along with Interrupt

eric commented 8 years ago

👍🏻

nextmat commented 8 years ago

LGTM

lmarburger commented 8 years ago
$ papertrail --version
papertrail version 0.9.15
$ papertrail | head -n 1
May 16 15:04:47 ...
/Users/larry/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/papertrail-0.9.15/lib/papertrail/cli.rb:182:in `write': Broken pipe @ io_write - <STDOUT> (Errno::EPIPE)
        from /Users/larry/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/papertrail-0.9.15/lib/papertrail/cli.rb:182:in `puts'
        from /Users/larry/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/papertrail-0.9.15/lib/papertrail/cli.rb:182:in `display_result'
        from /Users/larry/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/papertrail-0.9.15/lib/papertrail/cli.rb:190:in `block in display_results'
        from /Users/larry/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/papertrail-0.9.15/lib/papertrail/cli.rb:189:in `each'
        from /Users/larry/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/papertrail-0.9.15/lib/papertrail/cli.rb:189:in `display_results'
        from /Users/larry/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/papertrail-0.9.15/lib/papertrail/cli.rb:137:in `run'
        from /Users/larry/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/papertrail-0.9.15/bin/papertrail:5:in `<top (required)>'
        from /Users/larry/.rbenv/versions/2.2.3/bin/papertrail:23:in `load'
        from /Users/larry/.rbenv/versions/2.2.3/bin/papertrail:23:in `<main>'

$ gem install papertrail
Fetching: papertrail-0.9.16.gem (100%)
Successfully installed papertrail-0.9.16
1 gem installed
$ papertrail --version
papertrail version 0.9.16
$ papertrail | head -n 1
May 16 15:05:43 ...

happydog