logger: add caller info to default implementation (#1575)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-04-26 17:11:53 +03:00
committed by GitHub
parent 7253635cd3
commit a22da39e1c
3 changed files with 24 additions and 4 deletions

View File

@@ -14,6 +14,8 @@ type Options struct {
Fields map[string]interface{}
// It's common to set this to a file, or leave it default which is `os.Stderr`
Out io.Writer
// Caller skip frame count for file:line info
CallerSkipCount int
// Alternative options
Context context.Context
}
@@ -39,6 +41,13 @@ func WithOutput(out io.Writer) Option {
}
}
// WithCallerSkipCount set frame count to skip
func WithCallerSkipCount(c int) Option {
return func(args *Options) {
args.CallerSkipCount = c
}
}
func SetOption(k, v interface{}) Option {
return func(o *Options) {
if o.Context == nil {