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

This commit is contained in:
Omar Ismail authored and GitHub committed 2026-10-16 11:38:15 +00:00
1 parent af7620dcc8
commit 860b4ce635
2 files changed
+18 -1

No files matched your search

+6 -1
View File
@@ -550,7 +550,12 @@ func (cl *CustomLog) loggerAllowed(name string, isModule bool) bool {
for _, namespace := range cl.Include {
var hasPrefix bool
if isModule {
hasPrefix = strings.HasPrefix(namespace+".", name)
// the namespace is the module or one of its
// sub-loggers (e.g. "http.log.access" for "http")
hasPrefix = strings.HasPrefix(namespace+".", name) ||
// the namespace is a parent of the module (e.g.
// "http.handlers" for "http.handlers.file_server")
strings.HasPrefix(name, namespace+".")
} else {
hasPrefix = strings.HasPrefix(name, namespace+".")
}
+12
View File
@@ -87,6 +87,18 @@ func TestCustomLog_loggerAllowed(t *testing.T) {
},
want: true,
},
{
name: "include module from parent",
fields: fields{
Include: []string{"foo"},
Exclude: []string{},
},
args: args{
name: "foo.bar",
isModule: true,
},
want: true,
},
{
name: "excluded module is not printed",
fields: fields{