puma-dev
puma-dev copied to clipboard
Feature Request: Tail logs regardless of platform location
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!
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
- add an extra case statement for
logs
- grab the
logPath
fromsetup.go
- export it as a package variable so you can read it inside
command.go
asdev.LogPath
or similar. - pull in
github.com/hpcloud/tail
or similar or write your own! - 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