options.go 674 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package logger
  2. type Option func(*options)
  3. type options struct {
  4. driver string
  5. path string
  6. level string
  7. stdout string
  8. cap uint
  9. }
  10. func setDefault() options {
  11. return options{
  12. driver: "default",
  13. path: "temp/logs",
  14. level: "warn",
  15. stdout: "default",
  16. }
  17. }
  18. func WithType(s string) Option {
  19. return func(o *options) {
  20. o.driver = s
  21. }
  22. }
  23. func WithPath(s string) Option {
  24. return func(o *options) {
  25. o.path = s
  26. }
  27. }
  28. func WithLevel(s string) Option {
  29. return func(o *options) {
  30. o.level = s
  31. }
  32. }
  33. func WithStdout(s string) Option {
  34. return func(o *options) {
  35. o.stdout = s
  36. }
  37. }
  38. func WithCap(n uint) Option {
  39. return func(o *options) {
  40. o.cap = n
  41. }
  42. }