@@ -64,14 +64,9 @@ func LoggerTo(destWriter io.Writer, development bool) logr.Logger {
64
64
//
65
65
// Deprecated: use NewRaw() and the functional opts pattern instead:
66
66
//
67
- // NewRaw(UseDevMode(development))
67
+ // NewRaw(UseDevMode(development), WriteTo(destWriter), RawZapOpts(opts...) )
68
68
func RawLoggerTo (destWriter io.Writer , development bool , opts ... zap.Option ) * zap.Logger {
69
- o := func (o * Options ) {
70
- o .DestWritter = destWriter
71
- o .Development = development
72
- o .ZapOpts = opts
73
- }
74
- return NewRaw (o )
69
+ return NewRaw (UseDevMode (development ), WriteTo (destWriter ), RawZapOpts (opts ... ))
75
70
}
76
71
77
72
// Opts allows to manipulate Options
@@ -87,13 +82,46 @@ func UseDevMode(enabled bool) Opts {
87
82
}
88
83
89
84
// WriteTo configures the logger to write to the given io.Writer, instead of standard error.
90
- // See Options.WriterTo.
85
+ // See Options.DestWritter
91
86
func WriteTo (out io.Writer ) Opts {
92
87
return func (o * Options ) {
93
88
o .DestWritter = out
94
89
}
95
90
}
96
91
92
+ // Encoder configures how the logger will encode the output e.g JSON or console.
93
+ // See Options.Encoder
94
+ func Encoder (encoder zapcore.Encoder ) func (o * Options ) {
95
+ return func (o * Options ) {
96
+ o .Encoder = encoder
97
+ }
98
+ }
99
+
100
+ // Level sets the the minimum enabled logging level e.g Debug, Info
101
+ // See Options.Level
102
+ func Level (level * zap.AtomicLevel ) func (o * Options ) {
103
+ return func (o * Options ) {
104
+ o .Level = level
105
+ }
106
+ }
107
+
108
+ // StacktraceLevel configures the logger to record a stack trace for all messages at
109
+ // or above a given level.
110
+ // See Options.StacktraceLevel
111
+ func StacktraceLevel (stacktraceLevel * zap.AtomicLevel ) func (o * Options ) {
112
+ return func (o * Options ) {
113
+ o .StacktraceLevel = stacktraceLevel
114
+ }
115
+ }
116
+
117
+ // RawZapOpts allows appending arbitrary zap.Options to configure the underlying zap logger.
118
+ // See Options.ZapOpts
119
+ func RawZapOpts (zapOpts ... zap.Option ) func (o * Options ) {
120
+ return func (o * Options ) {
121
+ o .ZapOpts = append (o .ZapOpts , zapOpts ... )
122
+ }
123
+ }
124
+
97
125
// Options contains all possible settings
98
126
type Options struct {
99
127
// Development configures the logger to use a Zap development config
0 commit comments