@@ -76,6 +76,9 @@ type Config struct {
7676 // Logger line ending. Default: "\n" for the all modes except production
7777 LineEnding string `mapstructure:"line_ending"`
7878
79+ // SkipLineEnding determines if the logger should skip appending the default line ending to each log entry.
80+ SkipLineEnding bool `mapstructure:"skip_line_ending"`
81+
7982 // Encoding sets the logger's encoding. InitDefault values are "json" and
8083 // "console", as well as any third-party encodings registered via
8184 // RegisterEncoder.
@@ -117,6 +120,7 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
117120 MessageKey : "msg" ,
118121 StacktraceKey : zapcore .OmitKey ,
119122 LineEnding : cfg .LineEnding ,
123+ SkipLineEnding : cfg .SkipLineEnding ,
120124 EncodeLevel : zapcore .LowercaseLevelEncoder ,
121125 EncodeTime : utcEpochTimeEncoder ,
122126 EncodeDuration : zapcore .SecondsDurationEncoder ,
@@ -139,6 +143,7 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
139143 MessageKey : "msg" ,
140144 StacktraceKey : zapcore .OmitKey ,
141145 LineEnding : cfg .LineEnding ,
146+ SkipLineEnding : cfg .SkipLineEnding ,
142147 EncodeLevel : ColoredLevelEncoder ,
143148 EncodeName : ColoredNameEncoder ,
144149 EncodeTime : utcISO8601TimeEncoder ,
@@ -153,8 +158,9 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
153158 Level : zap .NewAtomicLevelAt (zap .InfoLevel ),
154159 Encoding : "console" ,
155160 EncoderConfig : zapcore.EncoderConfig {
156- MessageKey : "message" ,
157- LineEnding : cfg .LineEnding ,
161+ MessageKey : "message" ,
162+ LineEnding : cfg .LineEnding ,
163+ SkipLineEnding : cfg .SkipLineEnding ,
158164 },
159165 OutputPaths : []string {"stderr" },
160166 ErrorOutputPaths : []string {"stderr" },
@@ -172,6 +178,7 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
172178 MessageKey : "M" ,
173179 StacktraceKey : zapcore .OmitKey ,
174180 LineEnding : cfg .LineEnding ,
181+ SkipLineEnding : cfg .SkipLineEnding ,
175182 EncodeLevel : ColoredLevelEncoder ,
176183 EncodeName : ColoredNameEncoder ,
177184 EncodeTime : utcISO8601TimeEncoder ,
@@ -202,8 +209,7 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
202209 zCfg .ErrorOutputPaths = cfg .ErrorOutput
203210 }
204211
205- // if we also have a file logger specified in the config
206- // init it
212+ // if we also have a file logger specified in the config, init it
207213 // otherwise - return standard config
208214 if cfg .FileLogger != nil {
209215 // init absent options
@@ -238,10 +244,6 @@ func (cfg *Config) InitDefault() {
238244 if cfg .Level == "" {
239245 cfg .Level = "debug"
240246 }
241-
242- if cfg .LineEnding == "" {
243- cfg .LineEnding = zapcore .DefaultLineEnding
244- }
245247}
246248
247249func utcISO8601TimeEncoder (t time.Time , enc zapcore.PrimitiveArrayEncoder ) {
0 commit comments