* feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options.
This commit is contained in:
@@ -63,15 +63,15 @@ func (w *atomicWriter) Load() Writer {
|
||||
|
||||
func (w *atomicWriter) Store(v Writer) {
|
||||
w.lock.Lock()
|
||||
defer w.lock.Unlock()
|
||||
w.writer = v
|
||||
w.lock.Unlock()
|
||||
}
|
||||
|
||||
func (w *atomicWriter) Swap(v Writer) Writer {
|
||||
w.lock.Lock()
|
||||
defer w.lock.Unlock()
|
||||
old := w.writer
|
||||
w.writer = v
|
||||
w.lock.Unlock()
|
||||
return old
|
||||
}
|
||||
|
||||
@@ -109,6 +109,14 @@ func newFileWriter(c LogConf) (Writer, error) {
|
||||
if c.KeepDays > 0 {
|
||||
opts = append(opts, WithKeepDays(c.KeepDays))
|
||||
}
|
||||
if c.MaxBackups > 0 {
|
||||
opts = append(opts, WithMaxBackups(c.MaxBackups))
|
||||
}
|
||||
if c.MaxSize > 0 {
|
||||
opts = append(opts, WithMaxSize(c.MaxSize))
|
||||
}
|
||||
|
||||
opts = append(opts, WithLogRotationRuleType(c.RotationRuleType))
|
||||
|
||||
accessFile := path.Join(c.Path, accessFilename)
|
||||
errorFile := path.Join(c.Path, errorFilename)
|
||||
|
||||
Reference in New Issue
Block a user