Skip to content

Commit cdd18f7

Browse files
committed
feat: add skip field for caller
1 parent d1df933 commit cdd18f7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stackdriver.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ type Config struct {
2626

2727
Severity Severity
2828
AdditionalData AdditionalData
29+
30+
Skip int
2931
}
3032

3133
// NewConfig creates a config with default settings.
@@ -36,6 +38,7 @@ func NewConfig(projectId string) *Config {
3638
RequestLogOut: os.Stderr,
3739
ContextLogOut: os.Stdout,
3840
AdditionalData: AdditionalData{},
41+
Skip: 2,
3942
}
4043
}
4144

@@ -102,6 +105,7 @@ type ContextLogger struct {
102105
Severity Severity
103106
AdditionalData AdditionalData
104107
loggedSeverity []Severity
108+
Skip int
105109
}
106110

107111
// RequestContextLogger gets request-context logger for the request.
@@ -270,7 +274,7 @@ func (l *ContextLogger) write(severity Severity, msg string) error {
270274

271275
// get source location
272276
var location SourceLocation
273-
if pc, file, line, ok := runtime.Caller(2); ok {
277+
if pc, file, line, ok := runtime.Caller(l.Skip); ok {
274278
if function := runtime.FuncForPC(pc); function != nil {
275279
location.Function = function.Name()
276280
}

0 commit comments

Comments
 (0)