Skip to content

Commit 0e55277

Browse files
authored
slack-vitess-r14.0.5:Implement the Vitess Structure Logger VTSLogger (#80)
* Implement the Vitess Structure Logger VTSLoger Signed-off-by: Emad Habib <ehabib@slack-corp.com> * Downgrade zap from 1.24.0 to 1.23.0 Signed-off-by: Emad Habib <ehabib@slack-corp.com> * Ran go mod tidy Signed-off-by: Emad Habib <ehabib@slack-corp.com> * Fix help text test Signed-off-by: Emad Habib <ehabib@slack-corp.com> --------- Signed-off-by: Emad Habib <ehabib@slack-corp.com>
1 parent 49190df commit 0e55277

File tree

10 files changed

+237
-11
lines changed

10 files changed

+237
-11
lines changed

go.mod

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ require (
7676
github.com/spf13/pflag v1.0.5
7777
github.com/spf13/viper v1.8.1
7878
github.com/spyzhov/ajson v0.4.2
79-
github.com/stretchr/testify v1.7.1
79+
github.com/stretchr/testify v1.8.0
8080
github.com/tchap/go-patricia v2.2.6+incompatible
8181
github.com/tebeka/selenium v0.9.9
8282
github.com/tidwall/gjson v1.12.1
@@ -121,6 +121,16 @@ require (
121121

122122
require github.com/bndr/gotabulate v1.1.2
123123

124+
require (
125+
github.com/slok/noglog v0.2.0
126+
go.uber.org/zap v1.23.0
127+
)
128+
129+
require (
130+
go.uber.org/atomic v1.7.0 // indirect
131+
go.uber.org/multierr v1.6.0 // indirect
132+
)
133+
124134
require (
125135
cloud.google.com/go v0.81.0 // indirect
126136
github.com/BurntSushi/toml v0.3.1 // indirect
@@ -178,9 +188,6 @@ require (
178188
github.com/valyala/bytebufferpool v1.0.0 // indirect
179189
github.com/valyala/fasttemplate v1.0.1 // indirect
180190
go.opencensus.io v0.23.0 // indirect
181-
go.uber.org/atomic v1.7.0 // indirect
182-
go.uber.org/multierr v1.6.0 // indirect
183-
go.uber.org/zap v1.17.0 // indirect
184191
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
185192
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
186193
google.golang.org/appengine v1.6.7 // indirect

go.sum

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:l
123123
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
124124
github.com/aws/aws-sdk-go v1.34.2 h1:9vCknCdTAmmV4ht7lPuda7aJXzllXwEQyCMZKJHjBrM=
125125
github.com/aws/aws-sdk-go v1.34.2/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
126+
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
126127
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
127128
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
128129
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -666,6 +667,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
666667
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
667668
github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1 h1:acClJNSOjUrAUKW+ZneCZymCFDWtSaJG5YQl8FoOlyI=
668669
github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1/go.mod h1:Pgf1sZ2KrHK8vdRTV5UHGp80LT7HMUKuNAiKC402abY=
670+
github.com/slok/noglog v0.2.0 h1:1czu4l2EoJ8L92UwdSXXa1Y+c5TIjFAFm2P+mjej95E=
671+
github.com/slok/noglog v0.2.0/go.mod h1:TfKxwpEZPT+UA83bQ6RME146k0MM4e8mwHLf6bhcGDI=
669672
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
670673
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
671674
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
@@ -701,16 +704,18 @@ github.com/spyzhov/ajson v0.4.2 h1:JMByd/jZApPKDvNsmO90X2WWGbmT2ahDFp73QhZbg3s=
701704
github.com/spyzhov/ajson v0.4.2/go.mod h1:63V+CGM6f1Bu/p4nLIN8885ojBdt88TbLoSFzyqMuVA=
702705
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
703706
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
704-
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
705707
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
708+
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
709+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
706710
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
707711
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
708712
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
709713
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
710714
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
711715
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
712-
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
713716
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
717+
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
718+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
714719
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
715720
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
716721
github.com/tchap/go-patricia v2.2.6+incompatible h1:JvoDL7JSoIP2HDE8AbDH3zC8QBPxmzYe32HHy5yQ+Ck=
@@ -777,12 +782,14 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
777782
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
778783
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
779784
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
785+
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
780786
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
781787
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
782788
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
783789
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
784-
go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U=
785790
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
791+
go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
792+
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
786793
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
787794
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
788795
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=

go/flags/endtoend/vtgate.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ Usage of vtgate:
309309
logs at or above this threshold go to stderr (default 1)
310310
--stream_buffer_size int
311311
the number of bytes sent from vtgate for each stream call. It's recommended to keep this value in sync with vttablet's query-server-config-stream-buffer-size. (default 32768)
312+
--structured-logging
313+
whether to use structured logging (Zap) or the original (glog) logger
312314
--tablet_filters value
313315
Specifies a comma-separated list of 'keyspace|shard_name or keyrange' values to filter the tablets to watch
314316
--tablet_grpc_ca string

go/flags/endtoend/vttablet.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,8 @@ Usage of vttablet:
785785
logs at or above this threshold go to stderr (default 1)
786786
--stream_health_buffer_size uint
787787
max streaming health entries to buffer per streaming health client (default 20)
788+
--structured-logging
789+
whether to use structured logging (Zap) or the original (glog) logger
788790
--table-acl-config string
789791
path to table access checker config file; send SIGHUP to reload this file
790792
--table-acl-config-reload-interval duration

go/vt/logutil/vts_logger.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Copyright 2023 The Vitess Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package logutil
18+
19+
import (
20+
noglog "github.com/slok/noglog"
21+
"go.uber.org/zap"
22+
23+
"vitess.io/vitess/go/vt/log"
24+
)
25+
26+
type VTSLogger zap.SugaredLogger
27+
28+
// SetVTStructureLogger in-place noglog replacement with Zap's logger.
29+
func SetVTStructureLogger(conf *zap.Config) (vtSLogger *zap.SugaredLogger, err error) {
30+
var l *zap.Logger
31+
32+
// Use the passed configuration instead of the default configuration
33+
if conf == nil {
34+
defaultProdConf := zap.NewProductionConfig()
35+
conf = &defaultProdConf
36+
}
37+
38+
// Build configuration and generate a sugared logger
39+
l, err = conf.Build()
40+
vtSLogger = l.Sugar()
41+
42+
noglog.SetLogger(&noglog.LoggerFunc{
43+
DebugfFunc: func(f string, a ...interface{}) { vtSLogger.Debugf(f, a...) },
44+
InfofFunc: func(f string, a ...interface{}) { vtSLogger.Infof(f, a...) },
45+
WarnfFunc: func(f string, a ...interface{}) { vtSLogger.Warnf(f, a...) },
46+
ErrorfFunc: func(f string, a ...interface{}) { vtSLogger.Errorf(f, a...) },
47+
})
48+
49+
log.Flush = noglog.Flush
50+
log.Info = noglog.Info
51+
log.Infof = noglog.Infof
52+
log.InfoDepth = noglog.InfoDepth
53+
log.Warning = noglog.Warning
54+
log.Warningf = noglog.Warningf
55+
log.WarningDepth = noglog.WarningDepth
56+
log.Error = noglog.Error
57+
log.Errorf = noglog.Errorf
58+
log.ErrorDepth = noglog.ErrorDepth
59+
log.Exit = noglog.Exit
60+
log.Exitf = noglog.Exitf
61+
log.ExitDepth = noglog.ExitDepth
62+
log.Fatal = noglog.Fatal
63+
log.Fatalf = noglog.Fatalf
64+
log.FatalDepth = noglog.FatalDepth
65+
66+
return
67+
}

go/vt/logutil/vts_logger_test.go

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
Copyright 2023 The Vitess Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package logutil
18+
19+
import (
20+
"bytes"
21+
"encoding/json"
22+
"net/url"
23+
"testing"
24+
25+
"github.com/stretchr/testify/assert"
26+
27+
"go.uber.org/zap"
28+
"go.uber.org/zap/zapcore"
29+
30+
vtlog "vitess.io/vitess/go/vt/log"
31+
)
32+
33+
// MemorySink implements zap.Sink by writing all messages to a buffer.
34+
// It's used to capture the logs.
35+
type MemorySink struct {
36+
*bytes.Buffer
37+
}
38+
39+
// Implement Close and Sync as no-ops to satisfy the interface. The Write
40+
// method is provided by the embedded buffer.
41+
func (s *MemorySink) Close() error { return nil }
42+
func (s *MemorySink) Sync() error { return nil }
43+
44+
func SetupLoggerWithMemSink() (sink *MemorySink, err error) {
45+
// Create a sink instance, and register it with zap for the "memory" protocol.
46+
sink = &MemorySink{new(bytes.Buffer)}
47+
err = zap.RegisterSink("memory", func(*url.URL) (zap.Sink, error) {
48+
return sink, nil
49+
})
50+
if err != nil {
51+
return nil, err
52+
}
53+
54+
testLoggerConf := NewMemorySinkConfig()
55+
_, err = SetVTStructureLogger(&testLoggerConf)
56+
if err != nil {
57+
return nil, err
58+
}
59+
60+
return
61+
}
62+
63+
func NewMemorySinkConfig() zap.Config {
64+
return zap.Config{
65+
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
66+
Development: false,
67+
Sampling: &zap.SamplingConfig{
68+
Initial: 100,
69+
Thereafter: 100,
70+
},
71+
Encoding: "json",
72+
EncoderConfig: zap.NewProductionEncoderConfig(),
73+
OutputPaths: []string{"memory://"},
74+
ErrorOutputPaths: []string{"memory://"},
75+
}
76+
}
77+
78+
func TestVTSLogger_Replacing_glog(t *testing.T) {
79+
type logMsg struct {
80+
Level string `json:"level"`
81+
Msg string `json:"msg"`
82+
}
83+
84+
type testCase struct {
85+
name string
86+
logLevel zapcore.Level
87+
}
88+
89+
dummyLogMessage := "testing log"
90+
testCases := []testCase{
91+
{"log info", zap.InfoLevel},
92+
{"log warn", zap.WarnLevel},
93+
{"log error", zap.ErrorLevel},
94+
}
95+
96+
sink, err := SetupLoggerWithMemSink()
97+
assert.NoError(t, err)
98+
99+
for _, tc := range testCases {
100+
t.Run(tc.name, func(t *testing.T) {
101+
var loggingFunc func(format string, args ...interface{})
102+
var expectedLevel string
103+
104+
switch tc.logLevel {
105+
case zapcore.InfoLevel:
106+
loggingFunc = vtlog.Infof
107+
expectedLevel = "info"
108+
case zapcore.ErrorLevel:
109+
loggingFunc = vtlog.Errorf
110+
expectedLevel = "error"
111+
case zapcore.WarnLevel:
112+
loggingFunc = vtlog.Warningf
113+
expectedLevel = "warn"
114+
}
115+
116+
loggingFunc(dummyLogMessage)
117+
118+
// Unmarshal the captured log. This means we're getting a struct log.
119+
actualLog := logMsg{}
120+
err = json.Unmarshal(sink.Bytes(), &actualLog)
121+
assert.NoError(t, err)
122+
// Reset the sink so that it'll contain one log per test case.
123+
sink.Reset()
124+
125+
assert.Equal(t, expectedLevel, actualLog.Level)
126+
assert.Equal(t, dummyLogMessage, actualLog.Msg)
127+
128+
})
129+
}
130+
}

go/vt/servenv/grpc_auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ func GetAuthenticator(name string) func() (Authenticator, error) {
5454
}
5555

5656
// FakeAuthStreamInterceptor fake interceptor to test plugin
57-
func FakeAuthStreamInterceptor(srv any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
57+
func FakeAuthStreamInterceptor(srv any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { // nolint:revive
5858
if fakeDummyAuthenticate(stream.Context()) {
5959
return handler(srv, stream)
6060
}
6161
return status.Errorf(codes.Unauthenticated, "username and password must be provided")
6262
}
6363

6464
// FakeAuthUnaryInterceptor fake interceptor to test plugin
65-
func FakeAuthUnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
65+
func FakeAuthUnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { // nolint:revive
6666
if fakeDummyAuthenticate(ctx) {
6767
return handler(ctx, req)
6868
}

go/vt/servenv/grpc_server_auth_mtls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type MtlsAuthPlugin struct {
4646

4747
// Authenticate implements Authenticator interface. This method will be used inside a middleware in grpc_server to authenticate
4848
// incoming requests.
49-
func (ma *MtlsAuthPlugin) Authenticate(ctx context.Context, fullMethod string) (context.Context, error) {
49+
func (ma *MtlsAuthPlugin) Authenticate(ctx context.Context, fullMethod string) (context.Context, error) { // nolint:revive
5050
p, ok := peer.FromContext(ctx)
5151
if !ok {
5252
return nil, status.Errorf(codes.Unauthenticated, "no peer connection info")

go/vt/servenv/grpc_server_auth_static.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type StaticAuthPlugin struct {
5454

5555
// Authenticate implements AuthPlugin interface. This method will be used inside a middleware in grpc_server to authenticate
5656
// incoming requests.
57-
func (sa *StaticAuthPlugin) Authenticate(ctx context.Context, fullMethod string) (context.Context, error) {
57+
func (sa *StaticAuthPlugin) Authenticate(ctx context.Context, fullMethod string) (context.Context, error) { // nolint:revive
5858
if md, ok := metadata.FromIncomingContext(ctx); ok {
5959
if len(md["username"]) == 0 || len(md["password"]) == 0 {
6060
return nil, status.Errorf(codes.Unauthenticated, "username and password must be provided")

go/vt/servenv/servenv.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import (
3838
"syscall"
3939
"time"
4040

41+
"vitess.io/vitess/go/vt/logutil"
42+
4143
// register the HTTP handlers for profiling
4244
_ "net/http/pprof"
4345

@@ -64,6 +66,7 @@ var (
6466
_ = flag.Int("mem-profile-rate", 512*1024, "deprecated: use '-pprof=mem' instead")
6567
_ = flag.Int("mutex-profile-fraction", 0, "deprecated: use '-pprof=mutex' instead")
6668
catchSigpipe = flag.Bool("catch-sigpipe", false, "catch and ignore SIGPIPE on stdout and stderr if specified")
69+
useVTSLogger = flag.Bool("structured-logging", false, "whether to use structured logging (Zap) or the original (glog) logger")
6770

6871
// mutex used to protect the Init function
6972
mu sync.Mutex
@@ -244,6 +247,14 @@ func ParseFlags(cmd string) {
244247
os.Exit(0)
245248
}
246249

250+
if *useVTSLogger {
251+
// Replace glog logger with zap logger
252+
_, err := logutil.SetVTStructureLogger(nil)
253+
if err != nil {
254+
log.Exitf("error while setting the Zap logger: %s", err)
255+
}
256+
}
257+
247258
args := _flag.Args()
248259
if len(args) > 0 {
249260
flag.Usage()

0 commit comments

Comments
 (0)