File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,13 @@ func Encoder(encoder zapcore.Encoder) func(o *Options) {
7171 }
7272}
7373
74+ // JSONEncoder configures the logger to use a JSON Encoder
75+ func JSONEncoder (opts ... EncoderConfigOption ) func (o * Options ) {
76+ return func (o * Options ) {
77+ o .Encoder = newJSONEncoder (opts ... )
78+ }
79+ }
80+
7481func newJSONEncoder (opts ... EncoderConfigOption ) zapcore.Encoder {
7582 encoderConfig := zap .NewProductionEncoderConfig ()
7683 for _ , opt := range opts {
@@ -79,6 +86,13 @@ func newJSONEncoder(opts ...EncoderConfigOption) zapcore.Encoder {
7986 return zapcore .NewJSONEncoder (encoderConfig )
8087}
8188
89+ // ConsoleEncoder configures the logger to use a Console encoder
90+ func ConsoleEncoder (opts ... EncoderConfigOption ) func (o * Options ) {
91+ return func (o * Options ) {
92+ o .Encoder = newConsoleEncoder (opts ... )
93+ }
94+ }
95+
8296func newConsoleEncoder (opts ... EncoderConfigOption ) zapcore.Encoder {
8397 encoderConfig := zap .NewDevelopmentEncoderConfig ()
8498 for _ , opt := range opts {
You can’t perform that action at this time.
0 commit comments