Create log file if it doesn't exist #57
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes operable/cog#1123
Initially I thought of handling log rotation with this change as well, but decided against it for the time being. The current change fixes the original functionality that was intended to be present, and no more. To properly support log rotation, we'd need to either monitor inodes, reopen the file for each write (something that https://github.com/rifflock/lfshook actually does, and I initially thought to use, though that requires a little more work to mirror the functionality we currently have), or (my current inclination) implement a signal handler for
SIGHUP
which would reopen log files (and probably config files, too), in keeping with many other UNIX programs, and easily utilized with programs likelogrotate
. (Right now, aSIGHUP
will terminate the Relay process, which is default behavior for Go programs.)