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

Error if `--min-time` is in the future #75

Open kevinburkeshyp opened 8 years ago

kevinburkeshyp commented 8 years ago

I tried for example papertrail --min-time='16:06:53' (9am Pacific, but the log timestamps showed up as UTC). Papertrail prints no results and exits 0.

I know times are hard but it'd be nice if there was a warning that you were unlikely to get any results, as the timestamp is in the future, and/or an error.

kevinburkeshyp commented 8 years ago

(I should add I'm not sure how to get the CLI to parse the timestamp as UTC besides passing in the whole thing, e.g. --min-time='2016-05-16T16:03:00-00:00'. I tried '16:03:00 UTC', '16:03:00-00:00' but those both raised errors)

lmarburger commented 8 years ago

Times are hard, indeed. We just throw the times given to Chronic.parse and hope for the best. It works great—except in the case of time zones.

Looks like Chronic has specific support for full time-zoned-timestamps but nothing for simply the time + zone.

irb(main):032:0> Chronic.debug = true
=> true

irb(main):033:0> Chronic.parse '08:19:25 UTC'
-none
+---------------------------------------------------
| [08:19:25(repeater-time-29965, timezone) , utc(timezone) ]
+---------------------------------------------------
=> nil

irb(main):034:0> Chronic.parse '2015-04-01 08:19:25 UTC'
-date
Handler: handle_generic
+---------------------------------------------------
| [2015(repeater-time-72900, scalar, scalar-subsecond-2015, scalar-year-2015, timezone),
|  -(separator-dash, sign-minus),
|  04(repeater-time-14400, scalar, scalar-subsecond-4, scalar-second-4,
|     scalar-minute-4, scalar-hour-4, scalar-day-4, scalar-month-4, scalar-year-2004),
|  -(separator-dash, sign-minus),
|  01(repeater-time-3600, scalar, scalar-subsecond-1, scalar-second-1,
|     scalar-minute-1, scalar-hour-1, scalar-day-1, scalar-month-1, scalar-year-2001),
|  08:19:25(repeater-time-29965, timezone),
|  utc(timezone) ]
+---------------------------------------------------
=> 2015-04-01 08:19:25 UTC

I wonder if there's a way to default the date portion to today. I'll have to look into it.