Merge pull request 'add missing option' (#309) from logger-stacktrace into v3
Reviewed-on: #309
This commit is contained in:
commit
de4418189d
@ -6,7 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Option func
|
// Option func signature
|
||||||
type Option func(*Options)
|
type Option func(*Options)
|
||||||
|
|
||||||
// Options holds logger options
|
// Options holds logger options
|
||||||
@ -15,14 +15,16 @@ type Options struct {
|
|||||||
Out io.Writer
|
Out io.Writer
|
||||||
// Context holds exernal options
|
// Context holds exernal options
|
||||||
Context context.Context
|
Context context.Context
|
||||||
// Fields holds additional metadata
|
|
||||||
Fields []interface{}
|
|
||||||
// Name holds the logger name
|
// Name holds the logger name
|
||||||
Name string
|
Name string
|
||||||
// The logging level the logger should log
|
// Fields holds additional metadata
|
||||||
Level Level
|
Fields []interface{}
|
||||||
// CallerSkipCount number of frmaes to skip
|
// CallerSkipCount number of frmaes to skip
|
||||||
CallerSkipCount int
|
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
|
// 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
|
// WithCallerSkipCount set frame count to skip
|
||||||
func WithCallerSkipCount(c int) Option {
|
func WithCallerSkipCount(c int) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
|
@ -18,10 +18,10 @@ import (
|
|||||||
var reTrace = regexp.MustCompile(`.*/slog/logger\.go.*\n`)
|
var reTrace = regexp.MustCompile(`.*/slog/logger\.go.*\n`)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DefaultSourceKey string = slog.SourceKey
|
DefaultSourceKey = slog.SourceKey
|
||||||
DefaultTimeKey string = slog.TimeKey
|
DefaultTimeKey = slog.TimeKey
|
||||||
DefaultMessageKey string = slog.MessageKey
|
DefaultMessageKey = slog.MessageKey
|
||||||
DefaultLevelKey string = slog.LevelKey
|
DefaultLevelKey = slog.LevelKey
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user