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

Fix panic if logging directory cannot be generated #2571

Merged
merged 1 commit into from
Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ https://github.com/elastic/beats/compare/v5.0.0-alpha5...master[Check the HEAD d
- Fix array value support in -E CLI flag. {pull}2521[2521]
- Fix merging array values if -c CLI flag is used multiple times. {pull}2521[2521]
- Fix beats failing to start due to invalid duplicate key error in configuration file. {pull}2521[2521]
- Fix panic on non writable logging directory.

*Metricbeat*
- Fix module filters to work properly with drop_event filter. {issue}2249[2249]
Expand Down
11 changes: 7 additions & 4 deletions libbeat/logp/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ func SetToSyslog(toSyslog bool, prefix string) {
}

func SetToFile(toFile bool, rotator *FileRotator) error {
_log.toFile = toFile
if _log.toFile {
_log.rotator = rotator

if toFile {
err := rotator.CreateDirectory()
if err != nil {
return err
Expand All @@ -174,6 +171,12 @@ func SetToFile(toFile bool, rotator *FileRotator) error {
if err != nil {
return err
}

// Only assign rotator on no errors
_log.rotator = rotator
}

_log.toFile = toFile

return nil
}