From 03864b5df3f9f63c6d0c5bce733749c113120c40 Mon Sep 17 00:00:00 2001 From: Mangirdas Judeikis Date: Fri, 8 Sep 2023 10:46:23 +0300 Subject: [PATCH] CORE-3320: Add caller identity (#82) Add path to understand client origin Co-authored-by: Mangirdas --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index 4666271..c31e024 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,8 @@ import ( "net/http" "net/http/pprof" "os" + "path" + "runtime" "time" "github.com/bombsimon/logrusr/v4" @@ -55,6 +57,13 @@ func main() { logger := logrus.New() logger.SetLevel(logrus.Level(cfg.Log.Level)) + logger.SetReportCaller(true) + logger.Formatter = &logrus.TextFormatter{ + CallerPrettyfier: func(f *runtime.Frame) (string, string) { + filename := path.Base(f.File) + return fmt.Sprintf("%s()", f.Function), fmt.Sprintf("%s:%d", filename, f.Line) + }, + } client := castai.NewClient( logger,