From 860b4ce635ed1f5496bc48f5989b1acdc6ebaa10 Mon Sep 17 00:00:00 2001 From: Omar Ismail <33787232+omaresmael@users.noreply.github.com> Date: Fri, 16 Oct 2026 14:38:15 +0300 Subject: [PATCH] logging: include module logs from its parent namespace (#8221) --- logging.go | 7 ++++++- logging_test.go | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/logging.go b/logging.go index 341944947..150bde5d6 100644 --- a/logging.go +++ b/logging.go @@ -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+".") } diff --git a/logging_test.go b/logging_test.go index 960e9131f..9ea437df4 100644 --- a/logging_test.go +++ b/logging_test.go @@ -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{