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

replace %e with %d in strftime calls so that date fields are separated by just one space #86

Closed armchairlinguist closed 7 years ago

armchairlinguist commented 7 years ago

When running the example $ papertrail --min-time '1 minute ago' | cut -f 5 -d ' ' from the README on Dec (0)7 2016 in version 0.10.0 of the gem, the returned value was the system name and not the expected program name, which turned out to be due to the lack of a leading zero on the day number (different from the raw API result or the event viewer).

This change resolves that issue so that the fields in the date are consistently separated by one space (improving field number consistency overall).

Example output without the change:

Dec  8 09:29:44 agrant-mb apsd: APSMessageStore - Saving database. 
Dec  8 09:29:44 agrant-mb apsd: APSMessageStore - Destroying database. 

Example output with the change:

Dec 08 09:19:55 agrant-mb mdmclient: ApplePushService: <APSConnection: [hex_id]> Delivering did reconnect apsd 
Dec 08 09:19:55 agrant-mb mdmclient: ApplePushService: <APSConnection: [hex_id]> queuing call to delegate to tolerate setDelegate race 

Result of example without the change (returns system name):

$ papertrail --min-time '1 minute ago' | cut -f 5 -d ' '
agrant-mb
agrant-mb
agrant-mb

Result of example with the change (returns program name as expected):

$ papertrail --min-time '1 minute ago' | cut -f 5 -d ' '
taskgated:
taskgated:
taskgated:
taskgated:
taskgated: