Merge pull request 'add missing option' (#309) from logger-stacktrace into v3
Reviewed-on: #309
This commit is contained in:
commit
7f4afeb87b
@ -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) {
|
||||
|
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user