glogrotate (glog rotate) is a log clear and rotate for glog written in Go.
- This library support for deleting old logs.
- This library support for rotating logs.
go get github.com/cleey/glogrotate
import "github.com/cleey/glogrotate"
this example will rotate every hour(default) and clean the log files that creation time older than 24 hours.
glogrotate.Start(glogrotate.RotateOption{
Remain: time.Duration(time.Hour * 24),
})
this example will rotate every 3 seconds and clean the log files that creation time older than 10 seconds.
glogrotate.Start(glogrotate.RotateOption{
Dir: logDir, // default is glog log_dir
Prefix: programName, // default is current programName
RotateInterval: time.Duration(time.Second * 3), // default is 1 hour
CleanInterval: time.Duration(time.Second * 3), // default is 1 minute
Remain: time.Duration(time.Second * 10),
})
Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.
This program is under the terms of the MIT License. See LICENSE for the full license text.