log_cache_opts.go 1.0 KB

1234567891011121314151617181920212223242526272829
  1. package logger
  2. var externalValidators []LogOptValidator
  3. // RegisterExternalValidator adds the validator to the list of external validators.
  4. // External validators are used by packages outside this package that need to add their own validation logic.
  5. // This should only be called on package initialization.
  6. func RegisterExternalValidator(v LogOptValidator) {
  7. externalValidators = append(externalValidators, v)
  8. }
  9. // AddBuiltinLogOpts updates the list of built-in log opts. This allows other packages to supplement additional log options
  10. // without having to register an actual log driver. This is used by things that are more proxy log drivers and should
  11. // not be exposed as a usable log driver to the API.
  12. // This should only be called on package initialization.
  13. func AddBuiltinLogOpts(opts map[string]bool) {
  14. for k, v := range opts {
  15. builtInLogOpts[k] = v
  16. }
  17. }
  18. func validateExternal(cfg map[string]string) error {
  19. for _, v := range externalValidators {
  20. if err := v(cfg); err != nil {
  21. return err
  22. }
  23. }
  24. return nil
  25. }