config.go 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. package logx
  2. type LogRotationRuleType int
  3. const (
  4. LogRotationRuleTypeDaily LogRotationRuleType = iota
  5. LogRotationRuleTypeSizeLimit
  6. )
  7. // A LogConf is a logging config.
  8. type LogConf struct {
  9. ServiceName string `json:",optional"`
  10. Mode string `json:",default=console,options=[console,file,volume]"`
  11. Encoding string `json:",default=json,options=[json,plain]"`
  12. TimeFormat string `json:",optional"`
  13. Path string `json:",default=logs"`
  14. Level string `json:",default=info,options=[info,error,severe]"`
  15. Compress bool `json:",optional"`
  16. KeepDays int `json:",optional"`
  17. StackCooldownMillis int `json:",default=100"`
  18. // MaxBackups represents how many backup log files will be kept. 0 means all files will be kept forever.
  19. // Only take effect when RotationRuleType is `LogRotationRuleTypeSizeLimit`
  20. // NOTE: the level of option `KeepDays` will be higher. Even thougth `MaxBackups` sets 0, log files will
  21. // still be removed if the `KeepDays` limitation is reached.
  22. MaxBackups int `json:",default=0"`
  23. // MaxSize represents how much space the writing log file takes up. 0 means no limit. The unit is `MB`.
  24. // Only take effect when RotationRuleType is `LogRotationRuleTypeSizeLimit`
  25. MaxSize int `json:",default=0"`
  26. // RotationRuleType represents the type of log rotation rule. Default is DailyRotateRule.
  27. // 0: LogRotationRuleTypeDaily
  28. // 1: LogRotationRuleTypeSizeLimit
  29. RotationRuleType LogRotationRuleType `json:",default=0,options=[0,1]"`
  30. }