mirror of
https://github.com/caddyserver/caddy.git
synced 2026-11-11 19:37:55 +00:00
logging: include module logs from its parent namespace (#8221)
This commit is contained in:
1 parent
af7620dcc8
commit
860b4ce635
2 files changed
+18
-1
No files matched your search
+6
-1
@@ -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+".")
|
||||
}
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in new issue
Block a user