From 7e7b01fa3103e272ca4acc5a4fac6a9119c2623d Mon Sep 17 00:00:00 2001 From: Sylvain Rabot Date: Sat, 11 Aug 2018 14:57:00 +0200 Subject: [PATCH] Log real file's name and line pkg/kubectl/util/logs & staging/src/k8s.io/apiserver/pkg/util/logs use `glog.info(...)` but this function is not made to be wrapped because the underlying mechanism use a fixed call trace length to determine where the log has been emited. This results is having `logs.go:49` in the logs which is in the body of the wrapper function and thus useless. Instead use `glog.infoDepth(1, ...)` which tells the underlying mechanism to go back 1 more level in the call trace to determine where the log has been emitted. Signed-off-by: Sylvain Rabot --- pkg/kubectl/util/logs/logs.go | 2 +- staging/src/k8s.io/apiserver/pkg/util/logs/logs.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/util/logs/logs.go b/pkg/kubectl/util/logs/logs.go index eae42f795c..2b33372b5a 100644 --- a/pkg/kubectl/util/logs/logs.go +++ b/pkg/kubectl/util/logs/logs.go @@ -38,7 +38,7 @@ type GlogWriter struct{} // Write implements the io.Writer interface. func (writer GlogWriter) Write(data []byte) (n int, err error) { - glog.Info(string(data)) + glog.InfoDepth(1, string(data)) return len(data), nil } diff --git a/staging/src/k8s.io/apiserver/pkg/util/logs/logs.go b/staging/src/k8s.io/apiserver/pkg/util/logs/logs.go index c5ba084a59..35a5d04d6b 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/logs/logs.go +++ b/staging/src/k8s.io/apiserver/pkg/util/logs/logs.go @@ -46,7 +46,7 @@ type GlogWriter struct{} // Write implements the io.Writer interface. func (writer GlogWriter) Write(data []byte) (n int, err error) { - glog.Info(string(data)) + glog.InfoDepth(1, string(data)) return len(data), nil }