From fc133148dc26789b46b6694f1d245f974948fd50 Mon Sep 17 00:00:00 2001 From: andrey1s Date: Sun, 19 Sep 2021 18:42:33 +0300 Subject: [PATCH] update golang version --- .drone.yml | 34 ++-------------------------------- go.mod | 2 +- logger.go | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/.drone.yml b/.drone.yml index c020dfe..886aa50 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ name: default steps: - name: test - image: golang:1.14.2 + image: golang:1.17.1 volumes: - name: deps path: /go/src/mod @@ -11,40 +11,10 @@ steps: - go test - name: golangci-lint - image: golangci/golangci-lint:v1.29 + image: golangci/golangci-lint:v1.42 commands: - 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: - name: deps temp: {} diff --git a/go.mod b/go.mod index f5b814a..43d872c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module gitoa.ru/go-4devs/log -go 1.15 +go 1.17 require ( github.com/sirupsen/logrus v1.7.0 diff --git a/logger.go b/logger.go index 0a74cbd..387b5ed 100644 --- a/logger.go +++ b/logger.go @@ -323,6 +323,33 @@ type writer struct { 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) { return w.write(w.ctx, w.level, string(in), w.fields...) }