Contour: Switch to log.SetLogger to intercept Kubernetes logs

Created on 20 Oct 2020  路  7Comments  路  Source: projectcontour/contour

Please describe the problem you have

klogv2 has the https://godoc.org/github.com/kubernetes/klog#SetLogger API, which should let us drop the vaguely sketchy output stream we use to capture core Kubernetes log output.

good first issue help wanted kincleanup kinfeature lifecyclaccepted

All 7 comments

xref #3040

Nice to have.

currently the severity, file, and line are not being added by klog, TODO here: https://github.com/kubernetes/klog/blob/52c62e3b70a9a46101f33ebaf0b100ec55099975/klog.go#L916-L917

If we are ok with dropping the existing location=foo.go:line field from kubernetes logs (and using https://github.com/bombsimon/logrusr as a logr wrapper for logrus) then this is doable, otherwise we could PR upstream to k-log to add the fields (and write our own logr wrapper, though that seems unfortunate)

Also using SetLogger everything is an Info level log now: https://github.com/kubernetes/klog/blob/ea3b07f76a038d8ec9a2e52dc9a7840c817cfa8a/klog.go#L918-L922

Since https://github.com/go-logr/logr/pull/31 has been merged, had to close https://github.com/kubernetes/klog/pull/202 as its unlikely it will be merged

We will have to use a logr implementation that implements WithCallDepth to get the log location info we wanted to keep

Need to make a PR to klog to start using the new WithCallDepth: https://github.com/kubernetes/klog/pull/210

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jedsalazar picture jedsalazar  路  6Comments

williamhuangh picture williamhuangh  路  3Comments

annismckenzie picture annismckenzie  路  3Comments

phylake picture phylake  路  4Comments

davecheney picture davecheney  路  6Comments