puma-dev icon indicating copy to clipboard operation
puma-dev copied to clipboard

Feature Request: Tail logs regardless of platform location

Open andrewhavens opened this issue 7 years ago • 1 comments

I can never remember the location of the log file on OS X. I think it would be helpful to provide some sort of command to be able to tail the log. Maybe something like:

puma-dev logs --tail

this would then run tail -f ~/Library/Logs/puma-dev.log on OS X, or the Linux equivalent when running on Linux.

I've never written any Go code before, but would be willing to take a stab at this if I could get some approval/feedback/direction. Thanks!

andrewhavens avatar Mar 06 '17 23:03 andrewhavens

Sure! Here's how I'd go about it...

https://github.com/puma/puma-dev/blob/8907643a169565e11951e8ed0e425453108dcf56/cmd/puma-dev/command.go#L14-L21

That's where the "commands" (as distinct from flags) are handled. So, you'd need to

  1. add an extra case statement for logs
  2. grab the logPath from setup.go
  3. export it as a package variable so you can read it inside command.go as dev.LogPath or similar.
  4. pull in github.com/hpcloud/tail or similar or write your own!
  5. profit.

Then, don't forget to add a test in command_test.go that creates a tmp file, tails it WithStdoutCaptured and then verifies that the contents are the same.

In order to support the -tail flag on top of log, similar to what is done in link, you'd create a separate FlagSet to be able to parse the -tail flag. https://github.com/puma/puma-dev/blob/8907643a169565e11951e8ed0e425453108dcf56/cmd/puma-dev/command.go#L24-L25

nonrational avatar Mar 02 '20 03:03 nonrational