fix(log): change log level from warning to debug when unescape path params (#11359)

Closes #11186

Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
He Weiwei 2020-03-31 10:33:18 +08:00 committed by GitHub
parent fdb82ae4fa
commit 86d446ce81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -80,12 +80,12 @@ func unescapePathParams(params interface{}, fieldNames ...string) error {
for _, name := range fieldNames {
field := val.FieldByName(name)
if !field.IsValid() {
log.Warningf("field %s not found in params %v", name, params)
log.Debugf("field %s not found in %s", name, val.Type().Name())
continue
}
if !field.CanSet() {
log.Warningf("field %s can not be changed in params %v", name, params)
log.Debugf("field %s can not be changed in %s", name, val.Type().Name())
continue
}
@ -97,7 +97,7 @@ func unescapePathParams(params interface{}, fieldNames ...string) error {
}
field.SetString(v)
default:
log.Warningf("field %s can not be unescaped in params %v", name, params)
log.Debugf("field %s can not be unescaped in %s", name, val.Type().Name())
}
}

View File

@ -20,6 +20,7 @@ import (
func Test_unescapePathParams(t *testing.T) {
type Params struct {
ProjectID int64
ProjectName string
RepositoryName string
}
@ -38,6 +39,8 @@ func Test_unescapePathParams(t *testing.T) {
{"non ptr", args{str, []string{"RepositoryName"}}, true},
{"non struct", args{&str, []string{"RepositoryName"}}, true},
{"ptr of struct", args{&Params{}, []string{"RepositoryName"}}, false},
{"non string filed", args{&Params{}, []string{"ProjectID"}}, false},
{"filed not found", args{&Params{}, []string{"Name"}}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {