Skip to content

Commit 057a053

Browse files
committed
NoColor
1 parent 83c3ea3 commit 057a053

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

middleware/logger.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ type (
5454
// Optional. Default value DefaultLoggerConfig.CustomTimeFormat.
5555
CustomTimeFormat string `yaml:"custom_time_format"`
5656

57+
// Optional. Default value false.
58+
NoColor bool `yaml:"no_color"`
59+
5760
// Output is a writer where logs in JSON format are written.
5861
// Optional. Default value os.Stdout.
5962
Output io.Writer
@@ -99,6 +102,9 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
99102
config.template = fasttemplate.New(config.Format, "${", "}")
100103
config.colorer = color.New()
101104
config.colorer.SetOutput(config.Output)
105+
if config.NoColor {
106+
config.colorer.Disable()
107+
}
102108
config.pool = &sync.Pool{
103109
New: func() interface{} {
104110
return bytes.NewBuffer(make([]byte, 256))

0 commit comments

Comments
 (0)