add missing option
pr / test (pull_request) Successful in 1m46s Details
lint / lint (pull_request) Successful in 10m49s Details

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-03-04 23:03:55 +03:00
parent 4c7e1607d4
commit 2c44550897
2 changed files with 18 additions and 9 deletions

View File

@ -6,7 +6,7 @@ import (
"os"
)
// Option func
// Option func signature
type Option func(*Options)
// Options holds logger options
@ -15,14 +15,16 @@ type Options struct {
Out io.Writer
// Context holds exernal options
Context context.Context
// Fields holds additional metadata
Fields []interface{}
// Name holds the logger name
Name string
// The logging level the logger should log
Level Level
// Fields holds additional metadata
Fields []interface{}
// CallerSkipCount number of frmaes to skip
CallerSkipCount int
// Stacktrace controls writing of stacktaces on error
Stacktrace bool
// The logging level the logger should log
Level Level
}
// NewOptions creates new options struct
@ -61,6 +63,13 @@ func WithOutput(out io.Writer) Option {
}
}
// WithStacktrace controls writing stacktrace on error
func WithStacktrace(v bool) Option {
return func(o *Options) {
o.Stacktrace = v
}
}
// WithCallerSkipCount set frame count to skip
func WithCallerSkipCount(c int) Option {
return func(o *Options) {

View File

@ -18,10 +18,10 @@ import (
var reTrace = regexp.MustCompile(`.*/slog/logger\.go.*\n`)
var (
DefaultSourceKey string = slog.SourceKey
DefaultTimeKey string = slog.TimeKey
DefaultMessageKey string = slog.MessageKey
DefaultLevelKey string = slog.LevelKey
DefaultSourceKey = slog.SourceKey
DefaultTimeKey = slog.TimeKey
DefaultMessageKey = slog.MessageKey
DefaultLevelKey = slog.LevelKey
)
var (