mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-22 09:39:58 +08:00
Added LogRoller parser and entity.
The errors and logs can now have log rolling if provided by the user. The current customisable parameter of it are: The maximal size of the file before rolling. The maximal age/time of the file before rolling. The number of backups to keep.
This commit is contained in:
25
middleware/roller.go
Normal file
25
middleware/roller.go
Normal file
@ -0,0 +1,25 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
||||
type LogRoller struct {
|
||||
Filename string
|
||||
MaxSize int
|
||||
MaxAge int
|
||||
MaxBackups int
|
||||
LocalTime bool
|
||||
}
|
||||
|
||||
func (l LogRoller) GetLogWriter() io.Writer {
|
||||
return &lumberjack.Logger{
|
||||
Filename: l.Filename,
|
||||
MaxSize: l.MaxSize,
|
||||
MaxAge: l.MaxAge,
|
||||
MaxBackups: l.MaxBackups,
|
||||
LocalTime: l.LocalTime,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user