diff --git a/pkg/util/log/log.go b/pkg/util/log/log.go index 1049eb5dc75..6355e66b678 100644 --- a/pkg/util/log/log.go +++ b/pkg/util/log/log.go @@ -21,14 +21,13 @@ func GetLogger() *logrus.Entry { logrus.SetReportCaller(true) logrus.SetFormatter(&logrus.TextFormatter{ FullTimestamp: true, - CallerPrettyfier: RelativeFilePathPrettier, + CallerPrettyfier: relativeFilePathPrettier, }) return logrus.NewEntry(logrus.StandardLogger()) } -// RelativeFilePathPrettier changes absolute paths with relative paths -func RelativeFilePathPrettier(f *runtime.Frame) (string, string) { +func relativeFilePathPrettier(f *runtime.Frame) (string, string) { file := strings.TrimPrefix(f.File, repopath) function := f.Function[strings.LastIndexByte(f.Function, '/')+1:] return fmt.Sprintf("%s()", function), fmt.Sprintf(" %s:%d", file, f.Line) diff --git a/pkg/util/log/log_test.go b/pkg/util/log/log_test.go index ae652706903..fa3268b11d1 100644 --- a/pkg/util/log/log_test.go +++ b/pkg/util/log/log_test.go @@ -48,7 +48,7 @@ func TestRelativeFilePathPrettier(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - function, file := RelativeFilePathPrettier(tt.f) + function, file := relativeFilePathPrettier(tt.f) if function != tt.wantFunction { t.Error(function) }