Skip to content

Commit

Permalink
Merge pull request #222 from nspcc-dev/160-hide-log-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Jun 5, 2024
2 parents c965f16 + 1f2840e commit d7e7a9e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VERSION ?= "$(shell git describe --tags --match "v*" --dirty --always --abbrev=8
BUILD_OS ?= linux
BUILD_ARCH ?= amd64
GO_VERSION ?= 1.22
LINT_VERSION ?= v1.49.0
LINT_VERSION ?= v1.59.0

HUB_IMAGE ?= nspccdev/neofs-rest-gw
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
Expand Down
8 changes: 7 additions & 1 deletion cmd/neofs-rest-gw/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/spf13/viper"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"golang.org/x/term"
)

const (
Expand Down Expand Up @@ -437,7 +438,12 @@ func newLogger(v *viper.Viper) *zap.Logger {
c := zap.NewProductionConfig()
c.Level = zap.NewAtomicLevelAt(lvl)
c.Encoding = "console"
c.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
// If the program is run in TTY, the logger adds a timestamp to its entries.
if term.IsTerminal(int(os.Stdout.Fd())) {
c.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
} else {
c.EncoderConfig.EncodeTime = func(_ time.Time, _ zapcore.PrimitiveArrayEncoder) {}
}

l, err := c.Build(
zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/term v0.18.0
golang.org/x/text v0.14.0 // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand Down

0 comments on commit d7e7a9e

Please sign in to comment.