papertrail / papertrail-cli

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

Piping output to any other program prints an ugly message #73

Closed kevinburkeshyp closed 8 years ago

kevinburkeshyp commented 8 years ago

Maybe this is intended, but say I run papertrail blah | head -n 10 and the output has more than 10 lines, I get:

/Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/cli.rb:176:in `write': Broken pipe @ io_write - <STDOUT> (Errno::EPIPE)
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/cli.rb:176:in `puts'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/cli.rb:176:in `display_result'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/cli.rb:146:in `block in query_time_range'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/connection.rb:207:in `block (2 levels) in each_event'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/connection.rb:197:in `each'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/connection.rb:197:in `block in each_event'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/connection.rb:196:in `loop'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/connection.rb:196:in `each_event'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/cli.rb:142:in `query_time_range'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/lib/papertrail/cli.rb:127:in `run'
    from /Users/burke/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/papertrail-0.9.14/bin/papertrail:5:in `<top (required)>'
    from /Users/burke/.rbenv/versions/2.3.0/bin/papertrail:23:in `load'
    from /Users/burke/.rbenv/versions/2.3.0/bin/papertrail:23:in `<main>'
lmarburger commented 8 years ago

I can't believe we haven't into this before. We definitely need to handle that case.

The fix should be trivial. #74 is working fine for me. Let me make sure it works on Windows and then we'll cut a release today or Monday.

kevinburkeshyp commented 8 years ago

Huh, I can't reproduce this again this morning.

FWIW, we have one Papertrail account per running Heroku app, and we've deemed it too messy to switch for the moment - I'm running papertrail via the following Go wrapper: https://gist.github.com/kevinburkeshyp/575574d541bfbfa45e89ac8bc6f94505

lmarburger commented 8 years ago

I was reproducing it all morning using your example: papertrail | head -n 1 With the fix in #74 it works without the exception.

Out of curiosity, do you prefer to keep each Heroku app in a separate Papertrail account? I'm sure you know it's possible to consolidate them, but it's worth checking.

kevinburkeshyp commented 8 years ago

Yeah... we kinda started out that way, not realizing, but we might be switching away from Heroku soon and not sure it's worth it, especially if we might lose access to archives :(

johlym commented 8 years ago

Hi Kevin,

+1 thank you for finding this.

If you're worried about losing your archives, you can download them from Settings > Archives after getting to Papertrail via the Heroku Dashboard.

Unless I completely misunderstood what you meant.