cnoe-io / idpbuilder

Spin up a complete internal developer platform with only Docker required as a dependency.
https://cloud-native.slack.com/archives/C05TN9WFN5S
Apache License 2.0
174 stars 56 forks source link

Change logging format #370

Closed nabuskey closed 1 month ago

nabuskey commented 1 month ago

Currently, log outputs are hard to read. For example:

time=2024-08-26T20:22:19.468Z level=INFO msg="Creating kind cluster" logger=setup cluster=localdev
time=2024-08-26T20:22:36.409Z level=INFO msg="Done creating cluster" logger=setup cluster=localdev
time=2024-08-26T20:22:36.566Z level=INFO msg="Adding CRDs to the cluster" logger=setup
time=2024-08-26T20:22:37.377Z level=INFO msg="Setting up CoreDNS" logger=setup
time=2024-08-26T20:22:37.404Z level=INFO msg="Setting up TLS certificate" logger=setup
time=2024-08-26T20:22:37.425Z level=INFO msg="Creating localbuild resource" logger=setup
time=2024-08-26T20:22:37.425Z level=INFO msg="Starting EventSource" controller=localbuild controllerGroup=idpbuilder.cnoe.io controllerKind=Localbuild source="kind source: *v1alpha1.Localbuild"

There is a lot of repeated texts that adds no value.

With this PR log messages look like:

Aug 27 19:45:47 INFO Creating kind cluster logger=setup
Aug 27 19:45:47 INFO Runtime detected logger=setup provider=docker
Aug 27 19:45:47 INFO Cluster already exists logger=setup cluster=localdev
hi
Aug 27 19:45:47 INFO Adding CRDs to the cluster logger=setup
Aug 27 19:45:47 INFO Setting up CoreDNS logger=setup
Aug 27 19:45:47 INFO Setting up TLS certificate logger=setup
Aug 27 19:45:47 INFO Creating localbuild resource logger=setup
Aug 27 19:45:47 INFO Starting EventSource controller=localbuild controllerGroup=idpbuilder.cnoe.io controllerKind=Localbuild source=kind source: *v1alpha1.Localbuild

This also adds colored output option. Disabled by default.

image

cmoulliard commented 1 month ago

Don't forget to document how to enable/disable the colored output ;-)

nabuskey commented 1 month ago

Don't forget to document how to enable/disable the colored output ;-)

Yep. Plan is to make an issue to track it if this gets merged :)

tapas4java commented 1 month ago

Any problem if we make colored output default to true ? Anyway it's not going to break anything

nabuskey commented 1 month ago

Coloring is very subjective and I didn't want to impose what I like to others by default. If others like it over time, we can make it enabled by default imo.