Skip to content

[FEATURE] Pretty-print logging #237

@james-milligan

Description

@james-milligan

Requirements

Flagd currently prints structured logs in json format, when running flagd in the console this can cause the logs to be difficult to read.

the zap logger zap.Config struct contains the field Encoding which when set to console instead of json updates the logging structure as follows:

json

{"level":"info","ts":1671548378.306176,"caller":"runtime/runtime.go:84","msg":"configuration change (write) for flagKey headerColor (config/samples/example_flags.json)","component":"runtime"}
{"level":"info","ts":1671548378.3061912,"caller":"runtime/runtime.go:84","msg":"configuration change (write) for flagKey myBoolFlag (config/samples/example_flags.json)","component":"runtime"}
{"level":"info","ts":1671548378.306196,"caller":"runtime/runtime.go:84","msg":"configuration change (write) for flagKey myStringFlag (config/samples/example_flags.json)","component":"runtime"}
{"level":"info","ts":1671548378.306199,"caller":"runtime/runtime.go:84","msg":"configuration change (write) for flagKey myFloatFlag (config/samples/example_flags.json)","component":"runtime"}
{"level":"info","ts":1671548378.3062022,"caller":"runtime/runtime.go:84","msg":"configuration change (write) for flagKey myIntFlag (config/samples/example_flags.json)","component":"runtime"}

console

1.671549411055416e+09   info    runtime/runtime.go:84   configuration change (write) for flagKey myFloatFlag (config/samples/example_flags.json)        {"component": "runtime"}
1.6715494110554419e+09  info    runtime/runtime.go:84   configuration change (write) for flagKey myIntFlag (config/samples/example_flags.json)  {"component": "runtime"}
1.671549411055447e+09   info    runtime/runtime.go:84   configuration change (write) for flagKey myObjectFlag (config/samples/example_flags.json)       {"component": "runtime"}
1.671549411055451e+09   info    runtime/runtime.go:84   configuration change (write) for flagKey isColorYellow (config/samples/example_flags.json)      {"component": "runtime"}

This behaviour should be controlled via a viper flag, e.g. --log-encoding=console with a json default e.g. --log-encoding=json with a console default

Metadata

Metadata

Assignees

Labels

Needs TriageThis issue needs to be investigated by a maintainerenhancementNew feature or requestgood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions