File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -148,10 +148,10 @@ func (f *AllowedFormat) Set(s string) error {
148148
149149// Config is a struct containing configurable settings for the logger
150150type Config struct {
151- Level * AllowedLevel
152- Format * AllowedFormat
153- Style LogStyle
154- ioWriter io.Writer
151+ Level * AllowedLevel
152+ Format * AllowedFormat
153+ Style LogStyle
154+ Writer io.Writer
155155}
156156
157157// New returns a new slog.Logger. Each logged line will be annotated
@@ -162,8 +162,8 @@ func New(config *Config) *slog.Logger {
162162 _ = config .Level .Set ("info" )
163163 }
164164
165- if config .ioWriter == nil {
166- config .ioWriter = defaultWriter
165+ if config .Writer == nil {
166+ config .Writer = defaultWriter
167167 }
168168
169169 logHandlerOpts := & slog.HandlerOptions {
@@ -176,7 +176,7 @@ func New(config *Config) *slog.Logger {
176176 }
177177
178178 if config .Format != nil && config .Format .s == "json" {
179- return slog .New (slog .NewJSONHandler (config .ioWriter , logHandlerOpts ))
179+ return slog .New (slog .NewJSONHandler (config .Writer , logHandlerOpts ))
180180 }
181- return slog .New (slog .NewTextHandler (config .ioWriter , logHandlerOpts ))
181+ return slog .New (slog .NewTextHandler (config .Writer , logHandlerOpts ))
182182}
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ func TestDynamicLevels(t *testing.T) {
112112 for name , tc := range tests {
113113 t .Run (name , func (t * testing.T ) {
114114 buf .Reset () // Ensure buf is reset prior to tests
115- config := & Config {ioWriter : & buf , Style : tc .logStyle }
115+ config := & Config {Writer : & buf , Style : tc .logStyle }
116116 logger := New (config )
117117
118118 // Test that log level can be adjusted on-the-fly to debug and that a
You can’t perform that action at this time.
0 commit comments