logger: add caller info to default implementation (#1575)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		| @@ -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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user