1
0

config.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package logx
  2. // A LogConf is a logging config.
  3. type LogConf struct {
  4. // ServiceName represents the service name.
  5. ServiceName string `json:",optional"`
  6. // Mode represents the logging mode, default is `console`.
  7. // console: log to console.
  8. // file: log to file.
  9. // volume: used in k8s, prepend the hostname to the log file name.
  10. Mode string `json:",default=console,options=[console,file,volume]"`
  11. // Encoding represents the encoding type, default is `json`.
  12. // json: json encoding.
  13. // plain: plain text encoding, typically used in development.
  14. Encoding string `json:",default=json,options=[json,plain]"`
  15. // TimeFormat represents the time format, default is `2006-01-02T15:04:05.000Z07:00`.
  16. TimeFormat string `json:",optional"`
  17. // Path represents the log file path, default is `logs`.
  18. Path string `json:",default=logs"`
  19. // Level represents the log level, default is `info`.
  20. Level string `json:",default=info,options=[debug,info,error,severe]"`
  21. // MaxContentLength represents the max content bytes, default is no limit.
  22. MaxContentLength uint32 `json:",optional"`
  23. // Compress represents whether to compress the log file, default is `false`.
  24. Compress bool `json:",optional"`
  25. // Stat represents whether to log statistics, default is `true`.
  26. Stat bool `json:",default=true"`
  27. // KeepDays represents how many days the log files will be kept. Default to keep all files.
  28. // Only take effect when Mode is `file` or `volume`, both work when Rotation is `daily` or `size`.
  29. KeepDays int `json:",optional"`
  30. // StackCooldownMillis represents the cooldown time for stack logging, default is 100ms.
  31. StackCooldownMillis int `json:",default=100"`
  32. // MaxBackups represents how many backup log files will be kept. 0 means all files will be kept forever.
  33. // Only take effect when RotationRuleType is `size`.
  34. // Even though `MaxBackups` sets 0, log files will still be removed
  35. // if the `KeepDays` limitation is reached.
  36. MaxBackups int `json:",default=0"`
  37. // MaxSize represents how much space the writing log file takes up. 0 means no limit. The unit is `MB`.
  38. // Only take effect when RotationRuleType is `size`
  39. MaxSize int `json:",default=0"`
  40. // Rotation represents the type of log rotation rule. Default is `daily`.
  41. // daily: daily rotation.
  42. // size: size limited rotation.
  43. Rotation string `json:",default=daily,options=[daily,size]"`
  44. }