opt.go 726 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package fslog
  2. type FileOutputOpt func(*outFileConfig)
  3. func WithFilename(filename string) FileOutputOpt {
  4. return func(c *outFileConfig) {
  5. c.filename = filename
  6. }
  7. }
  8. func WithMaxSize(maxSize int) FileOutputOpt {
  9. return func(c *outFileConfig) {
  10. c.maxSize = maxSize
  11. }
  12. }
  13. func WithMaxAge(maxAge int) FileOutputOpt {
  14. return func(c *outFileConfig) {
  15. c.maxAge = maxAge
  16. }
  17. }
  18. func WithMaxBackups(maxBackups int) FileOutputOpt {
  19. return func(c *outFileConfig) {
  20. c.maxBackups = maxBackups
  21. }
  22. }
  23. func WithLocalTime(localTime bool) FileOutputOpt {
  24. return func(c *outFileConfig) {
  25. c.localTime = localTime
  26. }
  27. }
  28. func WithCompress(compress bool) FileOutputOpt {
  29. return func(c *outFileConfig) {
  30. c.Compress = compress
  31. }
  32. }