log.go 640 B

1234567891011121314151617181920212223242526272829303132333435
  1. package json
  2. import (
  3. "strings"
  4. "github.com/v2ray/v2ray-core/common/log"
  5. )
  6. type LogConfig struct {
  7. AccessLogValue string `json:"access"`
  8. ErrorLogValue string `json:"error"`
  9. LogLevelValue string `json:"loglevel"`
  10. }
  11. func (this *LogConfig) AccessLog() string {
  12. return this.AccessLogValue
  13. }
  14. func (this *LogConfig) ErrorLog() string {
  15. return this.ErrorLogValue
  16. }
  17. func (this *LogConfig) LogLevel() log.LogLevel {
  18. level := strings.ToLower(this.LogLevelValue)
  19. switch level {
  20. case "debug":
  21. return log.DebugLevel
  22. case "info":
  23. return log.InfoLevel
  24. case "error":
  25. return log.ErrorLevel
  26. default:
  27. return log.WarningLevel
  28. }
  29. }