config_adapter.go 867 B

12345678910111213141516171819202122232425262728293031
  1. package logger
  2. import "github.com/Wei-Shaw/sub2api/internal/config"
  3. func OptionsFromConfig(cfg config.LogConfig) InitOptions {
  4. return InitOptions{
  5. Level: cfg.Level,
  6. Format: cfg.Format,
  7. ServiceName: cfg.ServiceName,
  8. Environment: cfg.Environment,
  9. Caller: cfg.Caller,
  10. StacktraceLevel: cfg.StacktraceLevel,
  11. Output: OutputOptions{
  12. ToStdout: cfg.Output.ToStdout,
  13. ToFile: cfg.Output.ToFile,
  14. FilePath: cfg.Output.FilePath,
  15. },
  16. Rotation: RotationOptions{
  17. MaxSizeMB: cfg.Rotation.MaxSizeMB,
  18. MaxBackups: cfg.Rotation.MaxBackups,
  19. MaxAgeDays: cfg.Rotation.MaxAgeDays,
  20. Compress: cfg.Rotation.Compress,
  21. LocalTime: cfg.Rotation.LocalTime,
  22. },
  23. Sampling: SamplingOptions{
  24. Enabled: cfg.Sampling.Enabled,
  25. Initial: cfg.Sampling.Initial,
  26. Thereafter: cfg.Sampling.Thereafter,
  27. },
  28. }
  29. }