@marcel91200 / caddy Mirror · read-only / commits / 860b4ce6
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 02:15 UTC

logging: include module logs from its parent namespace (#8221)

Omar Ismail committed Oct 16, 2026 at 14:38 UTC 860b4ce635ed1f5496bc48f5989b1acdc6ebaa10
2 files changed +18 -1
logging.go
+6 -1
@@ -550,7 +550,12 @@ func (cl *CustomLog) loggerAllowed(name string, isModule bool) bool {
550 for _, namespace := range cl.Include {
551 var hasPrefix bool
552 if isModule {
553 - hasPrefix = strings.HasPrefix(namespace+".", name)
553 + // the namespace is the module or one of its
554 + // sub-loggers (e.g. "http.log.access" for "http")
555 + hasPrefix = strings.HasPrefix(namespace+".", name) ||
556 + // the namespace is a parent of the module (e.g.
557 + // "http.handlers" for "http.handlers.file_server")
558 + strings.HasPrefix(name, namespace+".")
559 } else {
560 hasPrefix = strings.HasPrefix(name, namespace+".")
561 }
logging_test.go
+12
@@ -87,6 +87,18 @@ func TestCustomLog_loggerAllowed(t *testing.T) {
87 },
88 want: true,
89 },
90 + {
91 + name: "include module from parent",
92 + fields: fields{
93 + Include: []string{"foo"},
94 + Exclude: []string{},
95 + },
96 + args: args{
97 + name: "foo.bar",
98 + isModule: true,
99 + },
100 + want: true,
101 + },
102 {
103 name: "excluded module is not printed",
104 fields: fields{