trentm / node-bunyan

a simple and fast JSON logging module for node.js services
Other
7.19k stars 518 forks source link

Wrong line endings when logging via ssh -t #435

Open fabue opened 8 years ago

fabue commented 8 years ago

We use ssh -t (request pty) to access logs from a remote machine. We pipe them to bunyan.

The requested tty needs \n\r as line endings, but bunyan uses \n, resulting in unreadable logs.

Example on MacOS: ssh -t dokku@host logs myapp -q -t | bunyan

trentm commented 8 years ago

@fabue How are the logs unreadable? Is there an extra blank line (perhaps the \r) per log record? Something else? Can you capture the resultant output to a file or a screenshot or something?

I couldn't reproduce using this log file which has CRLF line endings.

fabue commented 8 years ago

ssh -t dokku@host logs my-weather-service -q -t | bunyan prints out [1]:

[1]

ssh dokku@host logs my-weather-service -q -t | bunyan prints out [2]:

[2]

ssh -t dokku@host logs my-weather-service -q -t | bunyan --color | awk '{sub(/$/,"\r")}1' prints out [1]. awk '{sub(/$/,"\r")}1' fixes the line endings.

trentm commented 8 years ago

I must be missing something. Instead of ssh -t dokku@host logs myapp -q -t | bunyan... is the command more like ssh -t dokku@host 'logs myapp -q -t | bunyan'? In other words, is bunyan running on the remote host?

Also, apologies if I'm ignorant, but are you saying a pty is requiring apps to emit output using \n\r for line endings? I've never heard of that. Only: \n, or \r\n, or (one old pre-MacOSX mac) \r.