Browse Source

update golang version

pull/1/head
andrey1s 3 years ago
parent
commit
fc133148dc
  1. 34
      .drone.yml
  2. 2
      go.mod
  3. 27
      logger.go

34
.drone.yml

@ -3,7 +3,7 @@ name: default
steps: steps:
- name: test - name: test
image: golang:1.14.2 image: golang:1.17.1
volumes: volumes:
- name: deps - name: deps
path: /go/src/mod path: /go/src/mod
@ -11,40 +11,10 @@ steps:
- go test - go test
- name: golangci-lint - name: golangci-lint
image: golangci/golangci-lint:v1.29 image: golangci/golangci-lint:v1.42
commands: commands:
- golangci-lint run - golangci-lint run
- name: logrus golangci-lint
image: golangci/golangci-lint:v1.29
commands:
- cd logrus
- golangci-lint run
- name: logrus test
image: golang:1.14.2
volumes:
- name: deps
path: /go/src/mod
commands:
- cd logrus
- go test
- name: zap golangci-lint
image: golangci/golangci-lint:v1.29
commands:
- cd zap
- golangci-lint run
- name: zap test
image: golang:1.14.2
volumes:
- name: deps
path: /go/src/mod
commands:
- cd zap
- go test
volumes: volumes:
- name: deps - name: deps
temp: {} temp: {}

2
go.mod

@ -1,6 +1,6 @@
module gitoa.ru/go-4devs/log module gitoa.ru/go-4devs/log
go 1.15 go 1.17
require ( require (
github.com/sirupsen/logrus v1.7.0 github.com/sirupsen/logrus v1.7.0

27
logger.go

@ -323,6 +323,33 @@ type writer struct {
Logger Logger
} }
func (w writer) WithLevel(level level.Level) writer {
return writer{
level: level,
Logger: w.Logger,
ctx: w.ctx,
fields: w.fields,
}
}
func (w writer) WithContext(ctx context.Context) writer {
return writer{
level: w.level,
Logger: w.Logger,
ctx: ctx,
fields: w.fields,
}
}
func (w writer) WithFields(fields ...field.Field) writer {
return writer{
level: w.level,
Logger: w.Logger,
ctx: w.ctx,
fields: fields,
}
}
func (w writer) Write(in []byte) (int, error) { func (w writer) Write(in []byte) (int, error) {
return w.write(w.ctx, w.level, string(in), w.fields...) return w.write(w.ctx, w.level, string(in), w.fields...)
} }

Loading…
Cancel
Save