mirror of https://github.com/knative/pkg.git
Enrich the logs streamed in tests with useful information. (#480)
* Enrich the logs streamed in tests with useful information. - Level is very useful to spot errors at a glance. - Time is very helpful to be able to order the statements and notice time gaps. - Key helps identifying which ressource is being reconciled (could be a child resource). * Adjust timestamp, reduce level to only the first char.
This commit is contained in:
parent
b35531d473
commit
ca175939db
|
@ -47,6 +47,9 @@ type logger func(string, ...interface{})
|
|||
|
||||
var _ streamer = (*kubelogs)(nil)
|
||||
|
||||
// timeFormat defines a simple timestamp with millisecond granularity
|
||||
const timeFormat = "15:04:05.000"
|
||||
|
||||
func (k *kubelogs) init(t *testing.T) {
|
||||
k.keys = make(map[string]logger)
|
||||
|
||||
|
@ -132,8 +135,13 @@ func (k *kubelogs) handleLine(l string) {
|
|||
if !strings.Contains(line.Key, name) {
|
||||
continue
|
||||
}
|
||||
// TODO(mattmoor): What information do we want to display?
|
||||
logf("[%s] %s", line.Controller, line.Message)
|
||||
// E 15:04:05.000 [route-controller] [default/testroute-xyz] this is my message
|
||||
logf("%s %s [%s] [%s] %s",
|
||||
strings.ToUpper(string(line.Level[0])),
|
||||
line.Timestamp.Format(timeFormat),
|
||||
line.Controller,
|
||||
line.Key,
|
||||
line.Message)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue