Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create log file if it doesn't exist #57

Merged
merged 1 commit into from
Nov 4, 2016
Merged

Conversation

christophermaier
Copy link
Collaborator

@christophermaier christophermaier commented Nov 4, 2016

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 like logrotate. (Right now, a SIGHUP will terminate the Relay process, which is default behavior for Go programs.)

@@ -70,7 +70,7 @@ func configureLogger(config *config.Config) {
case "stdout":
log.SetOutput(os.Stdout)
default:
logFile, err := os.Open(config.LogPath)
logFile, err := os.OpenFile(config.LogPath, os.O_WRONLY | os.O_APPEND | os.O_CREATE, 0644)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@christophermaier christophermaier merged commit d956ed3 into master Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relay can't log to a file
2 participants