logger: conditional caller field

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2025-12-13 19:50:03 +03:00
parent 52c8f3da86
commit 13b01f59ee
2 changed files with 47 additions and 16 deletions

View File

@@ -8,6 +8,7 @@ import (
"slices"
"time"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/meter"
)
@@ -42,8 +43,10 @@ type Options struct {
Fields []interface{}
// ContextAttrFuncs contains funcs that executed before log func on context
ContextAttrFuncs []ContextAttrFunc
// callerSkipCount number of frmaes to skip
// callerSkipCount number of frames to skip
CallerSkipCount int
// AddCaller enables to get caller
AddCaller bool
// The logging level the logger should log
Level Level
// AddSource enabled writing source file and position in log
@@ -83,6 +86,12 @@ func NewOptions(opts ...Option) Options {
return options
}
func WithCallerEnabled(b bool) logger.Option {
return func(o *Options) {
o.AddCaller = b
}
}
// WithFatalFinalizers set logger.Fatal finalizers
func WithFatalFinalizers(fncs ...func(context.Context)) Option {
return func(o *Options) {