12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package logger
- type OutFileOptions struct {
- filename string
- maxSize int
- maxAge int
- maxBackups int
- localTime bool
- compress bool
- }
- func (options OutFileOptions) Filename() string {
- return options.filename
- }
- func (options OutFileOptions) MaxSize() int {
- return options.maxSize
- }
- func (options OutFileOptions) MaxAge() int {
- return options.maxAge
- }
- func (options OutFileOptions) MaxBackups() int {
- return options.maxBackups
- }
- func (options OutFileOptions) LocalTime() bool {
- return options.localTime
- }
- func (options OutFileOptions) Compress() bool {
- return options.compress
- }
- // FileOutputOpt 文件输出选项
- type FileOutputOpt func(*OutFileOptions)
- func WithFilename(filename string) FileOutputOpt {
- return func(c *OutFileOptions) {
- c.filename = filename
- }
- }
- func WithMaxSize(maxSize int) FileOutputOpt {
- return func(c *OutFileOptions) {
- c.maxSize = maxSize
- }
- }
- func WithMaxAge(maxAge int) FileOutputOpt {
- return func(c *OutFileOptions) {
- c.maxAge = maxAge
- }
- }
- func WithMaxBackups(maxBackups int) FileOutputOpt {
- return func(c *OutFileOptions) {
- c.maxBackups = maxBackups
- }
- }
- func WithLocalTime(localTime bool) FileOutputOpt {
- return func(c *OutFileOptions) {
- c.localTime = localTime
- }
- }
- func WithCompress(compress bool) FileOutputOpt {
- return func(c *OutFileOptions) {
- c.compress = compress
- }
- }
|