logging format 'human': continue printing prefixed fields if some are missing

This commit is contained in:
Christian Schwarz
2018-08-26 19:03:50 +02:00
parent a0f72b585b
commit ee5445777d
4 changed files with 7 additions and 10 deletions
-1
View File
@@ -91,4 +91,3 @@ func (j *PrometheusJob) JobStart(ctx context.Context) {
} }
} }
+1 -1
View File
@@ -26,7 +26,7 @@ type PullJob struct {
Prune PrunePolicy Prune PrunePolicy
Debug JobDebugSettings Debug JobDebugSettings
rep *replication.Replication rep *replication.Replication
} }
func parsePullJob(c JobParsingContext, name string, i map[string]interface{}) (j *PullJob, err error) { func parsePullJob(c JobParsingContext, name string, i map[string]interface{}) (j *PullJob, err error) {
+6 -7
View File
@@ -77,13 +77,12 @@ func (f *HumanFormatter) Format(e *logger.Entry) (out []byte, err error) {
prefixed := make(map[string]bool, len(prefixFields)+2) prefixed := make(map[string]bool, len(prefixFields)+2)
for _, field := range prefixFields { for _, field := range prefixFields {
val, ok := e.Fields[field].(string) val, ok := e.Fields[field].(string)
if ok { if !ok {
if !f.ignored(field) { continue
fmt.Fprintf(&line, "[%s]", val) }
prefixed[field] = true if !f.ignored(field) {
} fmt.Fprintf(&line, "[%s]", val)
} else { prefixed[field] = true
break
} }
} }
-1
View File
@@ -105,7 +105,6 @@ type Receiver interface {
fsrep.Receiver fsrep.Receiver
} }
type FilteredError struct{ fs string } type FilteredError struct{ fs string }
func NewFilteredError(fs string) *FilteredError { func NewFilteredError(fs string) *FilteredError {