MCPcopy
hub / github.com/caddyserver/caddy / provision

Method provision

logging.go:490–523  ·  view source on GitHub ↗
(ctx Context, logging *Logging)

Source from the content-addressed store, hash-verified

488}
489
490func (cl *CustomLog) provision(ctx Context, logging *Logging) error {
491 if err := cl.provisionCommon(ctx, logging); err != nil {
492 return err
493 }
494
495 // If both Include and Exclude lists are populated, then each item must
496 // be a superspace or subspace of an item in the other list, because
497 // populating both lists means that any given item is either a rule
498 // or an exception to another rule. But if the item is not a super-
499 // or sub-space of any item in the other list, it is neither a rule
500 // nor an exception, and is a contradiction. Ensure, too, that the
501 // sets do not intersect, which is also a contradiction.
502 if len(cl.Include) > 0 && len(cl.Exclude) > 0 {
503 // prevent intersections
504 for _, allow := range cl.Include {
505 if slices.Contains(cl.Exclude, allow) {
506 return fmt.Errorf("include and exclude must not intersect, but found %s in both lists", allow)
507 }
508 }
509
510 // ensure namespaces are nested
511 outer:
512 for _, allow := range cl.Include {
513 for _, deny := range cl.Exclude {
514 if strings.HasPrefix(allow+".", deny+".") ||
515 strings.HasPrefix(deny+".", allow+".") {
516 continue outer
517 }
518 }
519 return fmt.Errorf("when both include and exclude are populated, each element must be a superspace or subspace of one in the other list; check '%s' in include", allow)
520 }
521 }
522 return nil
523}
524
525func (cl *CustomLog) matchesModule(moduleID string) bool {
526 return cl.loggerAllowed(moduleID, true)

Callers

nothing calls this directly

Calls 1

provisionCommonMethod · 0.80

Tested by

no test coverage detected