ronantakizawa/codereview-bench huggingface dataset:
Repository: caddyserver/caddy
File: modules/caddyhttp/rewrite/rewrite.go (Go)

Code before:
		return rep.re.ReplaceAllString(pathOrRawPath, replace)
	})
}

func changePath(req *http.Request, newVal func(pathOrRawPath string) string) {
	req.URL.RawPath = newVal(req.URL.EscapedPath())
	if p, err := url.PathUnescape(req.URL.RawPath); err == nil && p != "" {
		req.URL.Path = p
	} else {
		req.URL.Path = newVal(req.URL.Path)
	}
	// RawPath is only set if it's different from the normalized Path (std lib)
	if req.URL.RawPath == req.URL.Path {
		req.URL.RawPath = ""
	}
}

// queryOps describes the operations to perform on a query like add, delete and replace fields
type queryOps struct {
	// Adds query parameters; does not replace any existing header fields.
	Add []queryOpsArguments `json:"add,omitempty"`

	// Sets query parameters; replaces existing header fields.
	Set []queryOpsArguments `json:"set,omitempty"`

	// Renames query keys
	Rename []queryOpsArguments `json:"rename,omitempty"`

	// Names of query parameters to delete
	Delete []string `json:"delete,omitempty"`
}

func (q *queryOps) do(r *http.Request, repl *caddy.Replacer) {
	query := r.URL.Query()

	for _, addParam := range q.Add {
		key := repl.ReplaceAll(addParam.Key, "")
		if key == "" {
			continue
		}
		val := repl.ReplaceAll(addParam.Val, "")
		query[key] = append(query[key], val)
	}

	for _, deleteParam := range q.Delete {
		param := repl.ReplaceAll(deleteParam, "")
		if param == "" {
			continue
		}
		delete(query, param)
	}

Review comment (suggestion):
```suggestion
	// Renames a query key from Key to Val, without affecting the value.
```

Code after:
	})
}

func changePath(req *http.Request, newVal func(pathOrRawPath string) string) {
	req.URL.RawPath = newVal(req.URL.EscapedPath())
	if p, err := url.PathUnescape(req.URL.RawPath); err == nil && p != "" {
		req.URL.Path = p
	} else {
		req.URL.Path = newVal(req.URL.Path)
	}
	// RawPath is only set if it's different from the normalized Path (std lib)
	if req.URL.RawPath == req.URL.Path {
		req.URL.RawPath = ""
	}
}

// queryOps describes the operations to perform on query keys: add, set, rename and delete.
type queryOps struct {
	// Renames a query key from Key to Val, without affecting the value.
	Rename []queryOpsArguments `json:"rename,omitempty"`

	// Sets query parameters; overwrites a query key with the given value.
	Set []queryOpsArguments `json:"set,omitempty"`

	// Adds query parameters; does not overwrite an existing query field,
	// and only appends an additional value for that key if any already exist.
	Add []queryOpsArguments `json:"add,omitempty"`

	// Deletes a given query key by name.
	Delete []string `json:"delete,omitempty"`
}

func (q *queryOps) do(r *http.Request, repl *caddy.Replacer) {
	query := r.URL.Query()

	for _, renameParam := range q.Rename {
		key := repl.ReplaceAll(renameParam.Key, "")
		val := repl.ReplaceAll(renameParam.Val, "")
		if key == "" || val == "" {
			continue
		}
		query[val] = query[key]
		delete(query, key)
	}

	for _, setParam := range q.Set {
		key := repl.ReplaceAll(setParam.Key, "")
		if key == "" {
			continue
		}
		val := repl.ReplaceAll(setParam.Val, "")
Repository: caddyserver/caddy
File: modules/caddyhttp/rewrite/rewrite.go (Go)

Code before:

func changePath(req *http.Request, newVal func(pathOrRawPath string) string) {
	req.URL.RawPath = newVal(req.URL.EscapedPath())
	if p, err := url.PathUnescape(req.URL.RawPath); err == nil && p != "" {
		req.URL.Path = p
	} else {
		req.URL.Path = newVal(req.URL.Path)
	}
	// RawPath is only set if it's different from the normalized Path (std lib)
	if req.URL.RawPath == req.URL.Path {
		req.URL.RawPath = ""
	}
}

// queryOps describes the operations to perform on a query like add, delete and replace fields
type queryOps struct {
	// Adds query parameters; does not replace any existing header fields.
	Add []queryOpsArguments `json:"add,omitempty"`

	// Sets query parameters; replaces existing header fields.
	Set []queryOpsArguments `json:"set,omitempty"`

	// Renames query keys
	Rename []queryOpsArguments `json:"rename,omitempty"`

	// Names of query parameters to delete
	Delete []string `json:"delete,omitempty"`
}

func (q *queryOps) do(r *http.Request, repl *caddy.Replacer) {
	query := r.URL.Query()

	for _, addParam := range q.Add {
		key := repl.ReplaceAll(addParam.Key, "")
		if key == "" {
			continue
		}
		val := repl.ReplaceAll(addParam.Val, "")
		query[key] = append(query[key], val)
	}

	for _, deleteParam := range q.Delete {
		param := repl.ReplaceAll(deleteParam, "")
		if param == "" {
			continue
		}
		delete(query, param)
	}

	for _, setParam := range q.Set {
		key := repl.ReplaceAll(setParam.Key, "")

Review comment (suggestion):
```suggestion
	// Deletes a given query key by name.
```

Code after:
func changePath(req *http.Request, newVal func(pathOrRawPath string) string) {
	req.URL.RawPath = newVal(req.URL.EscapedPath())
	if p, err := url.PathUnescape(req.URL.RawPath); err == nil && p != "" {
		req.URL.Path = p
	} else {
		req.URL.Path = newVal(req.URL.Path)
	}
	// RawPath is only set if it's different from the normalized Path (std lib)
	if req.URL.RawPath == req.URL.Path {
		req.URL.RawPath = ""
	}
}

// queryOps describes the operations to perform on query keys: add, set, rename and delete.
type queryOps struct {
	// Renames a query key from Key to Val, without affecting the value.
	Rename []queryOpsArguments `json:"rename,omitempty"`

	// Sets query parameters; overwrites a query key with the given value.
	Set []queryOpsArguments `json:"set,omitempty"`

	// Adds query parameters; does not overwrite an existing query field,
	// and only appends an additional value for that key if any already exist.
	Add []queryOpsArguments `json:"add,omitempty"`

	// Deletes a given query key by name.
	Delete []string `json:"delete,omitempty"`
}

func (q *queryOps) do(r *http.Request, repl *caddy.Replacer) {
	query := r.URL.Query()

	for _, renameParam := range q.Rename {
		key := repl.ReplaceAll(renameParam.Key, "")
		val := repl.ReplaceAll(renameParam.Val, "")
		if key == "" || val == "" {
			continue
		}
		query[val] = query[key]
		delete(query, key)
	}

	for _, setParam := range q.Set {
		key := repl.ReplaceAll(setParam.Key, "")
		if key == "" {
			continue
		}
		val := repl.ReplaceAll(setParam.Val, "")
		query[key] = []string{val}
	}
Repository: caddyserver/caddy
File: modules/caddyhttp/rewrite/rewrite.go (Go)

Code before:
		}
		val := repl.ReplaceAll(setParam.Val, "")
		query[key] = []string{val}
	}

	for _, renameParam := range q.Rename {
		key := repl.ReplaceAll(renameParam.Key, "")
		val := repl.ReplaceAll(renameParam.Val, "")
		if key == "" || val == "" {
			continue
		}
		query[val] = query[key]
		delete(query, key)
	}

	r.URL.RawQuery = query.Encode()
}

type queryOpsArguments struct {
	// A key in the query string. Note that query string keys may appear multiple times.
	Key string `json:"key,omitempty"`
	Val string `json:"val,omitempty"`
}

// Interface guard
var _ caddyhttp.MiddlewareHandler = (*Rewrite)(nil)


Review comment (suggestion):
```suggestion
	// The value for the given operation; for add and set, this is
	// simply the value of the query, and for rename this is the
	// query key to rename to.
	Val string `json:"val,omitempty"`
```

Code after:
		if key == "" {
			continue
		}
		val := repl.ReplaceAll(addParam.Val, "")
		query[key] = append(query[key], val)
	}

	for _, deleteParam := range q.Delete {
		param := repl.ReplaceAll(deleteParam, "")
		if param == "" {
			continue
		}
		delete(query, param)
	}

	r.URL.RawQuery = query.Encode()
}

type queryOpsArguments struct {
	// A key in the query string. Note that query string keys may appear multiple times.
	Key string `json:"key,omitempty"`

	// The value for the given operation; for add and set, this is
	// simply the value of the query, and for rename this is the
	// query key to rename to.
	Val string `json:"val,omitempty"`
}

// Interface guard
var _ caddyhttp.MiddlewareHandler = (*Rewrite)(nil)
Repository: caddyserver/caddy
File: modules/caddyhttp/encode/zstd/zstd.go (Go)

Code before:
		g.Level = zstd.SpeedDefault
	}
	return nil
}

// Validate validates g's configuration.
func (g Zstd) Validate() error {
	if g.Level < zstd.SpeedFastest {
		return fmt.Errorf("quality too low; must be >= %d", zstd.SpeedFastest)
	}
	if g.Level > zstd.SpeedBestCompression {
		return fmt.Errorf("quality too high; must be <= %d", zstd.SpeedBestCompression)
	}
	return nil
}

// AcceptEncoding returns the name of the encoding as
// used in the Accept-Encoding request headers.
func (Zstd) AcceptEncoding() string { return "zstd" }

// NewEncoder returns a new Zstandard writer.
func (z Zstd) NewEncoder() encode.Encoder {
	// The default of 8MB for the window is
	// too large for many clients, so we limit
	// it to 128K to lighten their load.
	writer, _ := zstd.NewWriter(nil, zstd.WithWindowSize(128<<10), zstd.WithEncoderConcurrency(1), zstd.WithZeroFrames(true), zstd.WithEncoderLevel(z.Level))
	return writer
}

// Interface guards
var (
	_ encode.Encoding       = (*Zstd)(nil)
	_ caddyfile.Unmarshaler = (*Zstd)(nil)
)


Review comment (suggestion):
This line's kinda long, let's adjust the syntax

```suggestion
	writer, _ := zstd.NewWriter(
		nil,
		zstd.WithWindowSize(128<<10), 
		zstd.WithEncoderConcurrency(1), 
		zstd.WithZeroFrames(true), 
		zstd.WithEncoderLevel(z.Level),
	)
```

Code after:
	z.Level = levelStr
	return nil
}

// Provision provisions z's configuration.
func (z *Zstd) Provision(ctx caddy.Context) error {
	if z.Level == "" {
		z.Level = zstd.SpeedDefault.String()
	}
	var ok bool
	if ok, z.level = zstd.EncoderLevelFromString(z.Level); !ok {
		return fmt.Errorf("unexpected compression level, use one of '%s', '%s', '%s', '%s'",
			zstd.SpeedFastest,
			zstd.SpeedDefault,
			zstd.SpeedBetterCompression,
			zstd.SpeedBestCompression,
		)
	}
	return nil
}

// AcceptEncoding returns the name of the encoding as
// used in the Accept-Encoding request headers.
func (Zstd) AcceptEncoding() string { return "zstd" }

// NewEncoder returns a new Zstandard writer.
func (z Zstd) NewEncoder() encode.Encoder {
	// The default of 8MB for the window is
	// too large for many clients, so we limit
	// it to 128K to lighten their load.
	writer, _ := zstd.NewWriter(
		nil,
		zstd.WithWindowSize(128<<10),
		zstd.WithEncoderConcurrency(1),
		zstd.WithZeroFrames(true),
		zstd.WithEncoderLevel(z.level),
	)
	return writer
}

// Interface guards
var (
	_ encode.Encoding       = (*Zstd)(nil)
	_ caddyfile.Unmarshaler = (*Zstd)(nil)
	_ caddy.Provisioner     = (*Zstd)(nil)
)
Repository: caddyserver/caddy
File: modules/caddyhttp/encode/zstd/zstd.go (Go)

Code before:
	if g.Level < zstd.SpeedFastest {
		return fmt.Errorf("quality too low; must be >= %d", zstd.SpeedFastest)
	}
	if g.Level > zstd.SpeedBestCompression {
		return fmt.Errorf("quality too high; must be <= %d", zstd.SpeedBestCompression)
	}
	return nil
}

// AcceptEncoding returns the name of the encoding as
// used in the Accept-Encoding request headers.
func (Zstd) AcceptEncoding() string { return "zstd" }

// NewEncoder returns a new Zstandard writer.
func (z Zstd) NewEncoder() encode.Encoder {
	// The default of 8MB for the window is
	// too large for many clients, so we limit
	// it to 128K to lighten their load.
	writer, _ := zstd.NewWriter(
		nil,
		zstd.WithWindowSize(128<<10), 
		zstd.WithEncoderConcurrency(1), 
		zstd.WithZeroFrames(true), 
		zstd.WithEncoderLevel(z.Level),
	)
	return writer
}

// Interface guards
var (
	_ encode.Encoding       = (*Zstd)(nil)
	_ caddyfile.Unmarshaler = (*Zstd)(nil)
)


Review comment (suggestion):
Oops my bad, I left in some spaces

```suggestion
	writer, _ := zstd.NewWriter(
		nil,
		zstd.WithWindowSize(128<<10),
		zstd.WithEncoderConcurrency(1),
		zstd.WithZeroFrames(true),
		zstd.WithEncoderLevel(z.Level),
	)
```

Code after:
		z.Level = zstd.SpeedDefault.String()
	}
	var ok bool
	if ok, z.level = zstd.EncoderLevelFromString(z.Level); !ok {
		return fmt.Errorf("unexpected compression level, use one of '%s', '%s', '%s', '%s'",
			zstd.SpeedFastest,
			zstd.SpeedDefault,
			zstd.SpeedBetterCompression,
			zstd.SpeedBestCompression,
		)
	}
	return nil
}

// AcceptEncoding returns the name of the encoding as
// used in the Accept-Encoding request headers.
func (Zstd) AcceptEncoding() string { return "zstd" }

// NewEncoder returns a new Zstandard writer.
func (z Zstd) NewEncoder() encode.Encoder {
	// The default of 8MB for the window is
	// too large for many clients, so we limit
	// it to 128K to lighten their load.
	writer, _ := zstd.NewWriter(
		nil,
		zstd.WithWindowSize(128<<10),
		zstd.WithEncoderConcurrency(1),
		zstd.WithZeroFrames(true),
		zstd.WithEncoderLevel(z.level),
	)
	return writer
}

// Interface guards
var (
	_ encode.Encoding       = (*Zstd)(nil)
	_ caddyfile.Unmarshaler = (*Zstd)(nil)
	_ caddy.Provisioner     = (*Zstd)(nil)
)
Repository: caddyserver/caddy
File: modules/caddyhttp/encode/zstd/zstd.go (Go)

Code before:
func (g *Zstd) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
	d.Next() // consume option name
	if !d.NextArg() {
		return nil
	}
	levelStr := d.Val()
	level, err := strconv.Atoi(levelStr)
	if err != nil {
		return err
	}
	g.Level = zstd.EncoderLevel(level)
	return nil
}

// Provision provisions g's configuration.
func (g *Zstd) Provision(ctx caddy.Context) error {
	if g.Level == 0 {
		g.Level = zstd.SpeedDefault
	}
	return nil
}

// Validate validates g's configuration.
func (g Zstd) Validate() error {
	if g.Level < zstd.SpeedFastest {
		return fmt.Errorf("quality too low; must be >= %d", zstd.SpeedFastest)
	}
	if g.Level > zstd.SpeedBestCompression {
		return fmt.Errorf("quality too high; must be <= %d", zstd.SpeedBestCompression)
	}
	return nil
}

// AcceptEncoding returns the name of the encoding as
// used in the Accept-Encoding request headers.
func (Zstd) AcceptEncoding() string { return "zstd" }

// NewEncoder returns a new Zstandard writer.
func (z Zstd) NewEncoder() encode.Encoder {
	// The default of 8MB for the window is
	// too large for many clients, so we limit
	// it to 128K to lighten their load.
	writer, _ := zstd.NewWriter(
		nil,
		zstd.WithWindowSize(128<<10),
		zstd.WithEncoderConcurrency(1),
		zstd.WithZeroFrames(true),
		zstd.WithEncoderLevel(z.Level),
	)
	return writer
}

Review comment (suggestion):
Although their values are from 1 to 4, we shouldn't rely on this behaviour. They are defined as [iota](https://github.com/klauspost/compress/blob/v1.17.7/zstd/encoder_options.go#L148).

Code after:
}

// UnmarshalCaddyfile sets up the handler from Caddyfile tokens.
func (z *Zstd) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
	d.Next() // consume option name
	if !d.NextArg() {
		return nil
	}
	levelStr := d.Val()
	if ok, _ := zstd.EncoderLevelFromString(levelStr); !ok {
		return d.Errf("unexpected compression level, use one of '%s', '%s', '%s', '%s'",
			zstd.SpeedFastest,
			zstd.SpeedBetterCompression,
			zstd.SpeedBestCompression,
			zstd.SpeedDefault,
		)
	}
	z.Level = levelStr
	return nil
}

// Provision provisions z's configuration.
func (z *Zstd) Provision(ctx caddy.Context) error {
	if z.Level == "" {
		z.Level = zstd.SpeedDefault.String()
	}
	var ok bool
	if ok, z.level = zstd.EncoderLevelFromString(z.Level); !ok {
		return fmt.Errorf("unexpected compression level, use one of '%s', '%s', '%s', '%s'",
			zstd.SpeedFastest,
			zstd.SpeedDefault,
			zstd.SpeedBetterCompression,
			zstd.SpeedBestCompression,
		)
	}
	return nil
}

// AcceptEncoding returns the name of the encoding as
// used in the Accept-Encoding request headers.
func (Zstd) AcceptEncoding() string { return "zstd" }

// NewEncoder returns a new Zstandard writer.
func (z Zstd) NewEncoder() encode.Encoder {
	// The default of 8MB for the window is
	// too large for many clients, so we limit
	// it to 128K to lighten their load.
	writer, _ := zstd.NewWriter(
		nil,
		zstd.WithWindowSize(128<<10),
		zstd.WithEncoderConcurrency(1),
Repository: caddyserver/caddy
File: modules/caddyhttp/encode/zstd/zstd.go (Go)

Code before:
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package caddyzstd

import (
	"github.com/klauspost/compress/zstd"

	"github.com/caddyserver/caddy/v2"
	"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
	"github.com/caddyserver/caddy/v2/modules/caddyhttp/encode"
)

func init() {
	caddy.RegisterModule(Zstd{})
}

// Zstd can create Zstandard encoders.
type Zstd struct {
	// Compression level refer to type constants value from zstd.SpeedFastest to zstd.SpeedBestCompression
	Level zstd.EncoderLevel `json:"level,omitempty"`
}

// CaddyModule returns the Caddy module information.
func (Zstd) CaddyModule() caddy.ModuleInfo {
	return caddy.ModuleInfo{
		ID:  "http.encoders.zstd",
		New: func() caddy.Module { return new(Zstd) },
	}
}

// UnmarshalCaddyfile sets up the handler from Caddyfile tokens.
func (z *Zstd) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
	d.Next() // consume option name
	if !d.NextArg() {
		return nil
	}
	levelStr := d.Val()
	ok, level := zstd.EncoderLevelFromString(levelStr)

	if !ok {
		return d.Errf("unexpected compression level, use one of '%s', '%s', '%s', '%s'",
			zstd.SpeedFastest,
			zstd.SpeedDefault,
			zstd.SpeedBetterCompression,
			zstd.SpeedBestCompression,
		)
	}

	z.Level = level

Review comment (suggestion):
Users reading the JSON docs won't know how to look at those constants. We should just list them out in the comment here for users to know what they can set.

Code after:
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package caddyzstd

import (
	"fmt"

	"github.com/klauspost/compress/zstd"

	"github.com/caddyserver/caddy/v2"
	"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
	"github.com/caddyserver/caddy/v2/modules/caddyhttp/encode"
)

func init() {
	caddy.RegisterModule(Zstd{})
}

// Zstd can create Zstandard encoders.
type Zstd struct {
	// The compression level. Accepted values: fastest, better, best, default.
	Level string `json:"level,omitempty"`

	// Compression level refer to type constants value from zstd.SpeedFastest to zstd.SpeedBestCompression
	level zstd.EncoderLevel
}

// CaddyModule returns the Caddy module information.
func (Zstd) CaddyModule() caddy.ModuleInfo {
	return caddy.ModuleInfo{
		ID:  "http.encoders.zstd",
		New: func() caddy.Module { return new(Zstd) },
	}
}

// UnmarshalCaddyfile sets up the handler from Caddyfile tokens.
func (z *Zstd) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
	d.Next() // consume option name
	if !d.NextArg() {
		return nil
	}
	levelStr := d.Val()
	if ok, _ := zstd.EncoderLevelFromString(levelStr); !ok {
		return d.Errf("unexpected compression level, use one of '%s', '%s', '%s', '%s'",
			zstd.SpeedFastest,
			zstd.SpeedBetterCompression,
			zstd.SpeedBestCompression,
			zstd.SpeedDefault,
		)
Repository: caddyserver/caddy
File: modules/logging/encoders.go (Go)

Code before:
			timeFormat = "2006/01/02 15:04:05.000000000"
		case "common_log":
			timeFormat = "02/Jan/2006:15:04:05 -0700"
		}
		timeFormatter = func(ts time.Time, encoder zapcore.PrimitiveArrayEncoder) {
			var time time.Time
			if lec.TimeLocal {
				time = ts.Local()
			} else {
				time = ts.UTC()
			}
			encoder.AppendString(time.Format(timeFormat))
		}
	}
	cfg.EncodeTime = timeFormatter

	// duration format
	var durFormatter zapcore.DurationEncoder
	switch lec.DurationFormat {
	case "", "seconds":
		durFormatter = zapcore.SecondsDurationEncoder
	case "nano":
		durFormatter = zapcore.NanosDurationEncoder
	case "string":
		durFormatter = zapcore.StringDurationEncoder
	case "ms":
		durFormatter = zapcore.MillisDurationEncoder
	}
	cfg.EncodeDuration = durFormatter

	// level format
	var levelFormatter zapcore.LevelEncoder
	switch lec.LevelFormat {
	case "", "lower":
		levelFormatter = zapcore.LowercaseLevelEncoder
	case "upper":
		levelFormatter = zapcore.CapitalLevelEncoder
	case "color":
		levelFormatter = zapcore.CapitalColorLevelEncoder
	}
	cfg.EncodeLevel = levelFormatter

	return cfg
}

var bufferpool = buffer.NewPool()

// Interface guards
var (
	_ zapcore.Encoder = (*ConsoleEncoder)(nil)
	_ zapcore.Encoder = (*JSONEncoder)(nil)

Review comment (suggestion):
The options are kinda misaligned I think, nano and ms aren't the same, should be nano and milli for example. But we could support all of them. So: ns/nano/nanos, s/second/seconds, ms/milli/millis

Code after:
			timeFormat = "2006/01/02 15:04:05.000000000"
		case "common_log":
			timeFormat = "02/Jan/2006:15:04:05 -0700"
		}
		timeFormatter = func(ts time.Time, encoder zapcore.PrimitiveArrayEncoder) {
			var time time.Time
			if lec.TimeLocal {
				time = ts.Local()
			} else {
				time = ts.UTC()
			}
			encoder.AppendString(time.Format(timeFormat))
		}
	}
	cfg.EncodeTime = timeFormatter

	// duration format
	var durFormatter zapcore.DurationEncoder
	switch lec.DurationFormat {
	case "s", "second", "seconds":
		durFormatter = zapcore.SecondsDurationEncoder
	case "ns", "nano", "nanos":
		durFormatter = zapcore.NanosDurationEncoder
	case "ms", "milli", "millis":
		durFormatter = zapcore.MillisDurationEncoder
	case "string":
		durFormatter = zapcore.StringDurationEncoder
	default:
		durFormatter = zapcore.SecondsDurationEncoder
	}
	cfg.EncodeDuration = durFormatter

	// level format
	var levelFormatter zapcore.LevelEncoder
	switch lec.LevelFormat {
	case "", "lower":
		levelFormatter = zapcore.LowercaseLevelEncoder
	case "upper":
		levelFormatter = zapcore.CapitalLevelEncoder
	case "color":
		levelFormatter = zapcore.CapitalColorLevelEncoder
	}
	cfg.EncodeLevel = levelFormatter

	return cfg
}

var bufferpool = buffer.NewPool()

// Interface guards
var (