1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package rotatelogs
- import (
- "time"
- "github.com/lestrrat-go/file-rotatelogs/internal/option"
- )
- const (
- optkeyClock = "clock"
- optkeyHandler = "handler"
- optkeyLinkName = "link-name"
- optkeyMaxAge = "max-age"
- optkeyRotationTime = "rotation-time"
- optkeyRotationSize = "rotation-size"
- optkeyRotationCount = "rotation-count"
- optkeyForceNewFile = "force-new-file"
- )
- func WithClock(c Clock) Option {
- return option.New(optkeyClock, c)
- }
- func WithLocation(loc *time.Location) Option {
- return option.New(optkeyClock, clockFn(func() time.Time {
- return time.Now().In(loc)
- }))
- }
- func WithLinkName(s string) Option {
- return option.New(optkeyLinkName, s)
- }
- func WithMaxAge(d time.Duration) Option {
- return option.New(optkeyMaxAge, d)
- }
- func WithRotationTime(d time.Duration) Option {
- return option.New(optkeyRotationTime, d)
- }
- func WithRotationSize(s int64) Option {
- return option.New(optkeyRotationSize, s)
- }
- func WithRotationCount(n uint) Option {
- return option.New(optkeyRotationCount, n)
- }
- func WithHandler(h Handler) Option {
- return option.New(optkeyHandler, h)
- }
- func ForceNewFile() Option {
- return option.New(optkeyForceNewFile, true)
- }
|