Browse Source

update ling and go version

pull/17/head
andrey 4 weeks ago
parent
commit
2fd0c1f9ec
  1. 4
      .drone.yml
  2. 2
      bench_test.go
  3. 2
      example/log.go
  4. 1
      field/encoder.go
  5. 1
      middleware.go

4
.drone.yml

@ -5,7 +5,7 @@ name: logger
steps:
- name: test
image: golang:1.21.5
image: golang:1.22
volumes:
- name: deps
path: /go/src/mod
@ -13,7 +13,7 @@ steps:
- go test
- name: golangci-lint
image: golangci/golangci-lint:v1.55
image: golangci/golangci-lint:v1.57
commands:
- golangci-lint run

2
bench_test.go

@ -166,7 +166,9 @@ func BenchmarkDisabledAccumulatedContext(b *testing.B) {
b.Run("4devs/log.Context", func(b *testing.B) {
b.ResetTimer()
logger := NewLogger().With(log.GoVersion("goversion"))
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.InfoKV(ctx, getMessage(0), fakeFields()...)

2
example/log.go

@ -21,7 +21,7 @@ func main() {
logger.AlertKV(ctx, "alert message new logger", field.String("string", "value"))
service(ctx, logger)
strLogger := log.New(log.WithFormat(log.FormatWithBracket())).With(log.WithSource(10, log.TrimPath), log.WithTime(log.KeyTime, time.RFC3339))
strLogger := log.New(log.WithFormat(log.FormatWithBracket(field.NewEncoderText()))).With(log.WithSource(10, log.TrimPath), log.WithTime(log.KeyTime, time.RFC3339))
strLogger.AlertKV(ctx, "alert message new txt logger", field.String("string", "value"))
service(ctx, strLogger)
}

1
field/encoder.go

@ -174,6 +174,7 @@ func needsQuoting(in string) bool {
if char != '\\' && (char == ' ' || char == '=' || !safeSet[char]) {
return true
}
i++
continue

1
middleware.go

@ -38,6 +38,7 @@ func With(logger Logger, mw ...Middleware) Logger {
if curI == lastI {
return logger(currentCtx, currentEntry)
}
curI++
n, err := mw[curI](currentCtx, currentEntry, chainHandler)
curI--

Loading…
Cancel
Save