[VOL-4760] Adding support for skipping functions in callstack
Change-Id: Iae903e5efad7b2b3aa0b8aa8402b0e64ecee7540
diff --git a/pkg/log/log.go b/pkg/log/log.go
index 7b1a123..6810fe1 100644
--- a/pkg/log/log.go
+++ b/pkg/log/log.go
@@ -660,3 +660,39 @@
func (l clogger) GetLogLevel() LogLevel {
return levelToLogLevel(cfgs[l.packageName].Level.Level())
}
+
+//UpdateCallerSkipLevel create new loggers for specified registered pacakges with the default updated caller skipltFields.
+//This will enable to skip wrapper file caller in caller info and stacktrace
+func UpdateCallerSkipLevel(skipLevel int) (CLogger, error) {
+ pkgName, _, _, _ := getCallerInfo()
+ if cfg, exist := cfgs[pkgName]; exist {
+ l, err := cfg.Build(zp.AddCallerSkip(skipLevel))
+ if err != nil {
+ return loggers[pkgName], err
+ }
+
+ // Update the existing zap logger instance
+ loggers[pkgName].log = l.Sugar()
+ loggers[pkgName].parent = l
+
+ return loggers[pkgName], nil
+ }
+
+ return loggers[pkgName], errors.New("Package Not Found")
+}
+
+//UpdateAllCallerSkipLevel create new loggers for all registered pacakges with the default updated caller skipltFields.
+//This will enable to skip wrapper file caller in caller info and stacktrace
+func UpdateAllCallerSkipLevel(skipLevel int) error {
+ for pkgName, cfg := range cfgs {
+ l, err := cfg.Build(zp.AddCallerSkip(skipLevel))
+ if err != nil {
+ return err
+ }
+
+ // Update the existing zap logger instance
+ loggers[pkgName].log = l.Sugar()
+ loggers[pkgName].parent = l
+ }
+ return nil
+}