Skip to content

Commit

Permalink
Fix config modify index validation log levels (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterklijn authored Jul 29, 2020
1 parent cf6fa53 commit 059c67c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
11 changes: 8 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ func (f *Field) String() string {

// Set the value of the field.
func (f *Field) Set(value string, version uint64) error {
if version != 0 && version <= f.version {
log.Warnf("version %d is older or same as the field's %s", version, f.name)
if version != 0 && version < f.version {
log.Errorf("version %d is older than the field's %q (version %d)", version, f.name, f.version)
return nil
}

if version != 0 && version == f.version {
log.Debugf("version %d is the same as field's %q", version, f.name)
return nil
}

Expand All @@ -93,7 +98,7 @@ func (f *Field) Set(value string, version uint64) error {
}

f.version = version
log.Infof("field %s updated with value %v, version: %d", f.name, f, version)
log.Infof("field %q updated with value %q, version: %d", f.name, f, version)
return nil
}

Expand Down
36 changes: 18 additions & 18 deletions harvester_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ import (
var (
csl *api.KV
secretLog = []string{
"INFO: field Name updated with value ***, version: ",
"INFO: seed value *** applied on field Name",
"INFO: field Name updated with value ***, version: ",
"INFO: consul value *** applied on field Name",
"INFO: field Age updated with value 18, version: ",
"INFO: seed value 18 applied on field Age",
"INFO: field Age updated with value 99, version: ",
"INFO: consul value 99 applied on field Age",
"INFO: field Balance updated with value 99.900000, version: ",
"INFO: seed value 99.900000 applied on field Balance",
"INFO: field Balance updated with value 111.100000, version: ",
"INFO: consul value 111.100000 applied on field Balance",
"INFO: field HasJob updated with value true, version: ",
"INFO: seed value true applied on field HasJob",
"INFO: field HasJob updated with value false, version: ",
"INFO: consul value false applied on field HasJob",
"INFO: plan for key harvester1/name created",
"INFO: plan for keyprefix harvester created",
`INFO: field "Name" updated with value "***", version: `,
`INFO: seed value *** applied on field Name`,
`INFO: field "Name" updated with value "***", version: `,
`INFO: consul value *** applied on field Name`,
`INFO: field "Age" updated with value "18", version: `,
`INFO: seed value 18 applied on field Age`,
`INFO: field "Age" updated with value "99", version: `,
`INFO: consul value 99 applied on field Age`,
`INFO: field "Balance" updated with value "99.900000", version: `,
`INFO: seed value 99.900000 applied on field Balance`,
`INFO: field "Balance" updated with value "111.100000", version: `,
`INFO: consul value 111.100000 applied on field Balance`,
`INFO: field "HasJob" updated with value "true", version: `,
`INFO: seed value true applied on field HasJob`,
`INFO: field "HasJob" updated with value "false", version: `,
`INFO: consul value false applied on field HasJob`,
`INFO: plan for key harvester1/name created`,
`INFO: plan for keyprefix harvester created`,
}
)

Expand Down

0 comments on commit 059c67c

Please sign in to comment.