-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
rotation - possibility of log rotations of 2,3,4,5,x minutes or hours #11602
Conversation
After: Log name based on file change Before: Log name based on rotation timestamp. This patch solves the problem of filenames containing 00-00-00 and adds the possibility of log rotations of 2,3,4,5 m or hours (not only 1m,1h) Important to mention that log rotation is based on logging.metrics.period. So if you put a time of 10s but logging.metrics.period default is 30s, it will rotate logs each 30s.
t.Format calls AppendFormat that breaks time into year/month/day/hour..etc.. Now yearly rotation will rotate with fixed format filebeat-2019-1
Merge branch 'master' of https://github.com/elastic/beats
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
@michalpristas I have correted the tests. There is a difference that before, you had fixed times and for all other time values an arbitrary time function. |
Will stash now |
@@ -61,38 +62,31 @@ func newIntervalRotator(interval time.Duration) (*intervalRotator, error) { | |||
func (r *intervalRotator) initialize() error { | |||
r.clock = realClock{} | |||
|
|||
switch r.interval { | |||
case time.Second: | |||
if r.interval < time.Minute { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: better use switch statements instead of if-elseif-else...
switch {
case r.interval < time.Minute:
...
case r.interval < time.Hour:
...
...
default:
...
}
How about defining some constants like const day = 24 * time.Hour
?
Moving this selection into an extra function makes it testable (often it's the most simplest code that contains the bug :) ).
@leopucci Could you please add a Changelog entry and update the PR as requested? |
Hi! We're labeling this issue as |
Hi! |
No description provided.