From 9eb1e47b8a3bc3e76cf6abd7c22182537c06ca76 Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Wed, 14 Dec 2022 16:47:46 +0100 Subject: [PATCH 01/10] Create a function to replace glog with PlanetScale log Signed-off-by: Emad Habib --- go.mod | 8 +- go.sum | 15 ++- go/vt/log/ps_log.go | 1 + go/vt/logutil/logger_test.go | 138 ++++++++++++++++++++++++++++ go/vt/logutil/planetscale_logger.go | 47 ++++++++++ 5 files changed, 205 insertions(+), 4 deletions(-) create mode 100644 go/vt/log/ps_log.go create mode 100644 go/vt/logutil/planetscale_logger.go diff --git a/go.mod b/go.mod index aeafac47acf..4759b79757d 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/fsnotify/fsnotify v1.4.9 github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab github.com/go-sql-driver/mysql v1.6.0 - github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b + github.com/golang/glog v1.0.0 github.com/golang/mock v1.5.0 github.com/golang/protobuf v1.5.2 github.com/golang/snappy v0.0.3 @@ -119,6 +119,9 @@ require ( github.com/bndr/gotabulate v1.1.2 github.com/nsf/jsondiff v0.0.0-20210926074059-1e845ec5d249 github.com/openark/golib v0.0.0-20210531070646-355f37940af8 + github.com/planetscale/log v0.0.0-20221118170849-fb599bc35c50 + github.com/slok/noglog v0.2.0 + go.uber.org/zap v1.19.1 golang.org/x/exp v0.0.0-20221023144134-a1e5550cf13e ) @@ -175,7 +178,6 @@ require ( go.opencensus.io v0.23.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - go.uber.org/zap v1.17.0 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/appengine v1.6.7 // indirect gopkg.in/inf.v0 v0.9.1 // indirect @@ -190,3 +192,5 @@ require ( k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.0.3 // indirect ) + +replace github.com/google/glog => github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e diff --git a/go.sum b/go.sum index bcff557d4bf..ef1270c91a6 100644 --- a/go.sum +++ b/go.sum @@ -117,6 +117,8 @@ github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:l github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.34.2 h1:9vCknCdTAmmV4ht7lPuda7aJXzllXwEQyCMZKJHjBrM= github.com/aws/aws-sdk-go v1.34.2/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -280,8 +282,9 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -606,6 +609,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +github.com/planetscale/log v0.0.0-20221118170849-fb599bc35c50 h1:yf0iVpE57riOj2+cLr6Fy6qX6eCLc5RLK3Kc70apP6c= +github.com/planetscale/log v0.0.0-20221118170849-fb599bc35c50/go.mod h1:SE8Q9QtLD8tfq8bM7rGLJnnWfmxt6mTXGkfGbft1vJI= github.com/planetscale/pargzip v0.0.0-20201116224723-90c7fc03ea8a h1:y0OpQ4+5tKxeh9+H+2cVgASl9yMZYV9CILinKOiKafA= github.com/planetscale/pargzip v0.0.0-20201116224723-90c7fc03ea8a/go.mod h1:GJFUzQuXIoB2Kjn1ZfDhJr/42D5nWOqRcIQVgCxTuIE= github.com/planetscale/vtprotobuf v0.3.0 h1:oMrOdDFHS1ADc0dHtC2EApxiM5xd0cQkZeibm0WgXiQ= @@ -660,6 +665,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1 h1:acClJNSOjUrAUKW+ZneCZymCFDWtSaJG5YQl8FoOlyI= github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1/go.mod h1:Pgf1sZ2KrHK8vdRTV5UHGp80LT7HMUKuNAiKC402abY= +github.com/slok/noglog v0.2.0 h1:1czu4l2EoJ8L92UwdSXXa1Y+c5TIjFAFm2P+mjej95E= +github.com/slok/noglog v0.2.0/go.mod h1:TfKxwpEZPT+UA83bQ6RME146k0MM4e8mwHLf6bhcGDI= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY= github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= @@ -766,12 +773,15 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1064,6 +1074,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/go/vt/log/ps_log.go b/go/vt/log/ps_log.go new file mode 100644 index 00000000000..7330d54052a --- /dev/null +++ b/go/vt/log/ps_log.go @@ -0,0 +1 @@ +package log diff --git a/go/vt/logutil/logger_test.go b/go/vt/logutil/logger_test.go index c34f8cf8ec3..ac0ab7e5ead 100644 --- a/go/vt/logutil/logger_test.go +++ b/go/vt/logutil/logger_test.go @@ -17,9 +17,20 @@ limitations under the License. package logutil import ( + "bytes" + "encoding/json" + "net/url" "testing" "time" + vtlog "vitess.io/vitess/go/vt/log" + + pslog "github.com/planetscale/log" + "github.com/stretchr/testify/assert" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" + "go.uber.org/zap/zaptest/observer" + "vitess.io/vitess/go/race" logutilpb "vitess.io/vitess/go/vt/proto/logutil" ) @@ -180,3 +191,130 @@ func TestTeeLogger(t *testing.T) { } } } + +func TestPSLogger(t *testing.T) { + t.Run("PlanetScale logger", func(t *testing.T) { + // Given + SetPlanetScaleLogger(nil) + observedZapCore, observedLogs := observer.New(zap.InfoLevel) + observedLoggerSugared := zap.New(observedZapCore).Sugar() + logLevels := [3]zapcore.Level{zap.InfoLevel, zap.WarnLevel, zap.ErrorLevel} + + // When + observedLoggerSugared.Infof("testing log") + observedLoggerSugared.Warnf("testing log") + observedLoggerSugared.Errorf("testing log") + + // Then + for idx, level := range logLevels { + expectLog := observer.LoggedEntry{ + Entry: zapcore.Entry{ + Level: level, + Message: "testing log", + }, + Context: nil, + } + actualLog := observedLogs.All()[idx] + + assert.Equal(t, expectLog.Level, actualLog.Level) + assert.Equal(t, expectLog.Message, actualLog.Message) + + } + + }) +} + +// MemorySink implements zap.Sink by writing all messages to a buffer. +type MemorySink struct { + *bytes.Buffer +} + +// Implement Close and Sync as no-ops to satisfy the interface. The Write +// method is provided by the embedded buffer. + +func (s *MemorySink) Close() error { return nil } +func (s *MemorySink) Sync() error { return nil } + +func TestPSLogger_Replacing_glog(t *testing.T) { + type logMsg struct { + Level string `json:"level"` + Msg string `json:"msg"` + } + + type testCase struct { + name string + logLevel zapcore.Level + } + + // Given + dummyLogMessage := "testing log" + + testCases := []testCase{ + {"log info", zapcore.InfoLevel}, + {"log warn", zapcore.WarnLevel}, + {"log error", zapcore.ErrorLevel}, + } + + // Create a sink instance, and register it with zap for the "memory" + // protocol. + sink := &MemorySink{new(bytes.Buffer)} + err := zap.RegisterSink("memory", func(*url.URL) (zap.Sink, error) { + return sink, nil + }) + if err != nil { + t.Fatal(err) + } + + testLoggerConf := pslog.NewPlanetScaleConfig(pslog.DetectEncoding(), pslog.InfoLevel) + testLoggerConf.OutputPaths = []string{"memory://", "stderr", "stdout"} + testLoggerConf.ErrorOutputPaths = []string{"memory://", "stderr", "stdout"} + SetPlanetScaleLogger(&testLoggerConf) + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + // When + var loggingFunc func(format string, args ...interface{}) + var expectedLevel string + + switch tc.logLevel { + case zapcore.InfoLevel: + { + loggingFunc = vtlog.Infof + expectedLevel = "info" + } + case zapcore.ErrorLevel: + { + loggingFunc = vtlog.Errorf + expectedLevel = "error" + } + case zapcore.WarnLevel: + { + loggingFunc = vtlog.Warningf + expectedLevel = "warn" + } + } + + loggingFunc(dummyLogMessage) + vtlog.Flush() + output := sink.String() + + if output == "" { + t.Error("output value is empty") + t.Fail() + return + } + + actualLog := logMsg{} + + err := json.Unmarshal([]byte(output), &actualLog) + if err != nil { + t.Error(err) + } + + // Then + assert.Equal(t, expectedLevel, actualLog.Level) + assert.Equal(t, dummyLogMessage, actualLog.Msg) + + }) + } +} diff --git a/go/vt/logutil/planetscale_logger.go b/go/vt/logutil/planetscale_logger.go new file mode 100644 index 00000000000..7e9da680419 --- /dev/null +++ b/go/vt/logutil/planetscale_logger.go @@ -0,0 +1,47 @@ +package logutil + +import ( + pslog "github.com/planetscale/log" + noglog "github.com/slok/noglog" + + "vitess.io/vitess/go/vt/log" +) + +type PSLogger pslog.SugaredLogger + +// SetPlanetScaleLogger in-place noglog replacement with PlanetScales' logger. +func SetPlanetScaleLogger(conf *pslog.Config) (psLogger *pslog.SugaredLogger) { + + if conf == nil { + configLogger, _ := conf.Build() + psLogger = configLogger.Sugar() + } else { + psLogger = pslog.NewPlanetScaleSugarLogger() + } + + noglog.SetLogger(&noglog.LoggerFunc{ + DebugfFunc: func(f string, a ...interface{}) { psLogger.Debugf(f, a...) }, + InfofFunc: func(f string, a ...interface{}) { psLogger.Infof(f, a...) }, + WarnfFunc: func(f string, a ...interface{}) { psLogger.Warnf(f, a...) }, + ErrorfFunc: func(f string, a ...interface{}) { psLogger.Errorf(f, a...) }, + }) + + log.Flush = noglog.Flush + log.Info = noglog.Info + log.Infof = noglog.Infof + log.InfoDepth = noglog.InfoDepth + log.Warning = noglog.Warning + log.Warningf = noglog.Warningf + log.WarningDepth = noglog.WarningDepth + log.Error = noglog.Error + log.Errorf = noglog.Errorf + log.ErrorDepth = noglog.ErrorDepth + log.Exit = noglog.Exit + log.Exitf = noglog.Exitf + log.ExitDepth = noglog.ExitDepth + log.Fatal = noglog.Fatal + log.Fatalf = noglog.Fatalf + log.FatalDepth = noglog.FatalDepth + + return +} From 91a600d217d3b15b5c88ab10595155c45698435f Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Thu, 15 Dec 2022 13:09:46 +0100 Subject: [PATCH 02/10] Add test case for replacing glog Signed-off-by: Emad Habib --- go/vt/log/ps_log.go | 1 - go/vt/logutil/logger_test.go | 138 --------------------- go/vt/logutil/planetscale_logger.go | 4 +- go/vt/logutil/planetscale_logger_test.go | 145 +++++++++++++++++++++++ 4 files changed, 147 insertions(+), 141 deletions(-) delete mode 100644 go/vt/log/ps_log.go create mode 100644 go/vt/logutil/planetscale_logger_test.go diff --git a/go/vt/log/ps_log.go b/go/vt/log/ps_log.go deleted file mode 100644 index 7330d54052a..00000000000 --- a/go/vt/log/ps_log.go +++ /dev/null @@ -1 +0,0 @@ -package log diff --git a/go/vt/logutil/logger_test.go b/go/vt/logutil/logger_test.go index ac0ab7e5ead..c34f8cf8ec3 100644 --- a/go/vt/logutil/logger_test.go +++ b/go/vt/logutil/logger_test.go @@ -17,20 +17,9 @@ limitations under the License. package logutil import ( - "bytes" - "encoding/json" - "net/url" "testing" "time" - vtlog "vitess.io/vitess/go/vt/log" - - pslog "github.com/planetscale/log" - "github.com/stretchr/testify/assert" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" - "go.uber.org/zap/zaptest/observer" - "vitess.io/vitess/go/race" logutilpb "vitess.io/vitess/go/vt/proto/logutil" ) @@ -191,130 +180,3 @@ func TestTeeLogger(t *testing.T) { } } } - -func TestPSLogger(t *testing.T) { - t.Run("PlanetScale logger", func(t *testing.T) { - // Given - SetPlanetScaleLogger(nil) - observedZapCore, observedLogs := observer.New(zap.InfoLevel) - observedLoggerSugared := zap.New(observedZapCore).Sugar() - logLevels := [3]zapcore.Level{zap.InfoLevel, zap.WarnLevel, zap.ErrorLevel} - - // When - observedLoggerSugared.Infof("testing log") - observedLoggerSugared.Warnf("testing log") - observedLoggerSugared.Errorf("testing log") - - // Then - for idx, level := range logLevels { - expectLog := observer.LoggedEntry{ - Entry: zapcore.Entry{ - Level: level, - Message: "testing log", - }, - Context: nil, - } - actualLog := observedLogs.All()[idx] - - assert.Equal(t, expectLog.Level, actualLog.Level) - assert.Equal(t, expectLog.Message, actualLog.Message) - - } - - }) -} - -// MemorySink implements zap.Sink by writing all messages to a buffer. -type MemorySink struct { - *bytes.Buffer -} - -// Implement Close and Sync as no-ops to satisfy the interface. The Write -// method is provided by the embedded buffer. - -func (s *MemorySink) Close() error { return nil } -func (s *MemorySink) Sync() error { return nil } - -func TestPSLogger_Replacing_glog(t *testing.T) { - type logMsg struct { - Level string `json:"level"` - Msg string `json:"msg"` - } - - type testCase struct { - name string - logLevel zapcore.Level - } - - // Given - dummyLogMessage := "testing log" - - testCases := []testCase{ - {"log info", zapcore.InfoLevel}, - {"log warn", zapcore.WarnLevel}, - {"log error", zapcore.ErrorLevel}, - } - - // Create a sink instance, and register it with zap for the "memory" - // protocol. - sink := &MemorySink{new(bytes.Buffer)} - err := zap.RegisterSink("memory", func(*url.URL) (zap.Sink, error) { - return sink, nil - }) - if err != nil { - t.Fatal(err) - } - - testLoggerConf := pslog.NewPlanetScaleConfig(pslog.DetectEncoding(), pslog.InfoLevel) - testLoggerConf.OutputPaths = []string{"memory://", "stderr", "stdout"} - testLoggerConf.ErrorOutputPaths = []string{"memory://", "stderr", "stdout"} - SetPlanetScaleLogger(&testLoggerConf) - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - // When - var loggingFunc func(format string, args ...interface{}) - var expectedLevel string - - switch tc.logLevel { - case zapcore.InfoLevel: - { - loggingFunc = vtlog.Infof - expectedLevel = "info" - } - case zapcore.ErrorLevel: - { - loggingFunc = vtlog.Errorf - expectedLevel = "error" - } - case zapcore.WarnLevel: - { - loggingFunc = vtlog.Warningf - expectedLevel = "warn" - } - } - - loggingFunc(dummyLogMessage) - vtlog.Flush() - output := sink.String() - - if output == "" { - t.Error("output value is empty") - t.Fail() - return - } - - actualLog := logMsg{} - - err := json.Unmarshal([]byte(output), &actualLog) - if err != nil { - t.Error(err) - } - - // Then - assert.Equal(t, expectedLevel, actualLog.Level) - assert.Equal(t, dummyLogMessage, actualLog.Msg) - - }) - } -} diff --git a/go/vt/logutil/planetscale_logger.go b/go/vt/logutil/planetscale_logger.go index 7e9da680419..e58129efb11 100644 --- a/go/vt/logutil/planetscale_logger.go +++ b/go/vt/logutil/planetscale_logger.go @@ -11,8 +11,8 @@ type PSLogger pslog.SugaredLogger // SetPlanetScaleLogger in-place noglog replacement with PlanetScales' logger. func SetPlanetScaleLogger(conf *pslog.Config) (psLogger *pslog.SugaredLogger) { - - if conf == nil { + // Use the passed configuration instead of the default configuration + if conf != nil { configLogger, _ := conf.Build() psLogger = configLogger.Sugar() } else { diff --git a/go/vt/logutil/planetscale_logger_test.go b/go/vt/logutil/planetscale_logger_test.go new file mode 100644 index 00000000000..168c0bf7fe5 --- /dev/null +++ b/go/vt/logutil/planetscale_logger_test.go @@ -0,0 +1,145 @@ +package logutil + +import ( + "bytes" + "encoding/json" + "net/url" + "testing" + + "github.com/stretchr/testify/assert" + + pslog "github.com/planetscale/log" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" + "go.uber.org/zap/zaptest/observer" + + vtlog "vitess.io/vitess/go/vt/log" +) + +// MemorySink implements zap.Sink by writing all messages to a buffer. +// It's used to capture the logs. +type MemorySink struct { + *bytes.Buffer +} + +// Implement Close and Sync as no-ops to satisfy the interface. The Write +// method is provided by the embedded buffer. +func (s *MemorySink) Close() error { return nil } +func (s *MemorySink) Sync() error { return nil } + +func SetupLoggerWithMemSink() (sink *MemorySink, err error) { + // Create a sink instance, and register it with zap for the "memory" + // protocol. + sink = &MemorySink{new(bytes.Buffer)} + err = zap.RegisterSink("memory", func(*url.URL) (zap.Sink, error) { + return sink, nil + }) + if err != nil { + return nil, err + } + + testLoggerConf := pslog.NewPlanetScaleConfig(pslog.DetectEncoding(), pslog.InfoLevel) + testLoggerConf.OutputPaths = []string{"memory://"} + testLoggerConf.ErrorOutputPaths = []string{"memory://"} + SetPlanetScaleLogger(&testLoggerConf) + + return +} + +func TestPSLogger_Replacing_glog(t *testing.T) { + type logMsg struct { + Level string `json:"level"` + Msg string `json:"msg"` + } + + type testCase struct { + name string + logLevel zapcore.Level + } + + // Given + dummyLogMessage := "testing log" + testCases := []testCase{ + {"log info", zapcore.InfoLevel}, + {"log warn", zapcore.WarnLevel}, + {"log error", zapcore.ErrorLevel}, + } + + sink, err := SetupLoggerWithMemSink() + if err != nil { + t.Fatal(err) + } + + // When + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var loggingFunc func(format string, args ...interface{}) + var expectedLevel string + + switch tc.logLevel { + case zapcore.InfoLevel: + { + loggingFunc = vtlog.Infof + expectedLevel = "info" + } + case zapcore.ErrorLevel: + { + loggingFunc = vtlog.Errorf + expectedLevel = "error" + } + case zapcore.WarnLevel: + { + loggingFunc = vtlog.Warningf + expectedLevel = "warn" + } + } + + loggingFunc(dummyLogMessage) + output := sink.String() + sink.Reset() + + actualLog := logMsg{} + err := json.Unmarshal([]byte(output), &actualLog) + if err != nil { + t.Error(err) + } + + // Then + assert.Equal(t, expectedLevel, actualLog.Level) + assert.Equal(t, dummyLogMessage, actualLog.Msg) + + }) + } +} + +func TestPSLogger(t *testing.T) { + t.Run("PlanetScale logger", func(t *testing.T) { + // Given + SetPlanetScaleLogger(nil) + observedZapCore, observedLogs := observer.New(zap.InfoLevel) + observedLoggerSugared := zap.New(observedZapCore).Sugar() + logLevels := [3]zapcore.Level{zap.InfoLevel, zap.WarnLevel, zap.ErrorLevel} + + // When + observedLoggerSugared.Infof("testing log") + observedLoggerSugared.Warnf("testing log") + observedLoggerSugared.Errorf("testing log") + + // Then + for idx, level := range logLevels { + expectLog := observer.LoggedEntry{ + Entry: zapcore.Entry{ + Level: level, + Message: "testing log", + }, + Context: nil, + } + actualLog := observedLogs.All()[idx] + + assert.Equal(t, expectLog.Level, actualLog.Level) + assert.Equal(t, expectLog.Message, actualLog.Message) + + } + + }) +} From e3171136eb97ba84c7927c89e023766527a91335 Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Thu, 15 Dec 2022 13:47:32 +0100 Subject: [PATCH 03/10] Remove one test Signed-off-by: Emad Habib --- go/vt/logutil/planetscale_logger_test.go | 47 ++++-------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/go/vt/logutil/planetscale_logger_test.go b/go/vt/logutil/planetscale_logger_test.go index 168c0bf7fe5..53d7a39c20d 100644 --- a/go/vt/logutil/planetscale_logger_test.go +++ b/go/vt/logutil/planetscale_logger_test.go @@ -11,7 +11,6 @@ import ( pslog "github.com/planetscale/log" "go.uber.org/zap" "go.uber.org/zap/zapcore" - "go.uber.org/zap/zaptest/observer" vtlog "vitess.io/vitess/go/vt/log" ) @@ -60,9 +59,9 @@ func TestPSLogger_Replacing_glog(t *testing.T) { // Given dummyLogMessage := "testing log" testCases := []testCase{ - {"log info", zapcore.InfoLevel}, - {"log warn", zapcore.WarnLevel}, - {"log error", zapcore.ErrorLevel}, + {"log info", pslog.InfoLevel}, + {"log warn", pslog.WarnLevel}, + {"log error", pslog.ErrorLevel}, } sink, err := SetupLoggerWithMemSink() @@ -95,14 +94,14 @@ func TestPSLogger_Replacing_glog(t *testing.T) { } loggingFunc(dummyLogMessage) - output := sink.String() - sink.Reset() - + // Unmarshal the captured log. This means we're getting a struct log. actualLog := logMsg{} - err := json.Unmarshal([]byte(output), &actualLog) + err = json.Unmarshal(sink.Bytes(), &actualLog) if err != nil { t.Error(err) } + // Reset the sink so that it'll contain one log per test case. + sink.Reset() // Then assert.Equal(t, expectedLevel, actualLog.Level) @@ -111,35 +110,3 @@ func TestPSLogger_Replacing_glog(t *testing.T) { }) } } - -func TestPSLogger(t *testing.T) { - t.Run("PlanetScale logger", func(t *testing.T) { - // Given - SetPlanetScaleLogger(nil) - observedZapCore, observedLogs := observer.New(zap.InfoLevel) - observedLoggerSugared := zap.New(observedZapCore).Sugar() - logLevels := [3]zapcore.Level{zap.InfoLevel, zap.WarnLevel, zap.ErrorLevel} - - // When - observedLoggerSugared.Infof("testing log") - observedLoggerSugared.Warnf("testing log") - observedLoggerSugared.Errorf("testing log") - - // Then - for idx, level := range logLevels { - expectLog := observer.LoggedEntry{ - Entry: zapcore.Entry{ - Level: level, - Message: "testing log", - }, - Context: nil, - } - actualLog := observedLogs.All()[idx] - - assert.Equal(t, expectLog.Level, actualLog.Level) - assert.Equal(t, expectLog.Message, actualLog.Message) - - } - - }) -} From cf25de9373b441e3726759c9bd017371754d37f0 Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Thu, 15 Dec 2022 16:45:25 +0100 Subject: [PATCH 04/10] Add flag for PS Logger usage Signed-off-by: Emad Habib --- go/vt/servenv/servenv.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/go/vt/servenv/servenv.go b/go/vt/servenv/servenv.go index a55c3241ca0..997e3ede980 100644 --- a/go/vt/servenv/servenv.go +++ b/go/vt/servenv/servenv.go @@ -82,6 +82,7 @@ var ( onCloseTimeout = time.Nanosecond catchSigpipe bool maxStackSize = 64 * 1024 * 1024 + usePSLogger bool ) // RegisterFlags installs the flags used by Init, Run, and RunDefault. @@ -98,6 +99,8 @@ func RegisterFlags() { // pid_file.go fs.StringVar(&pidFile, "pid_file", pidFile, "If set, the process will write its pid to the named file, and delete it on graceful shutdown.") + // Logging + fs.BoolVar(&usePSLogger, "structure_logging", usePSLogger, "whether to use structure logging (Planet Scale Log) logger or the original (glog) logger") }) } @@ -322,6 +325,11 @@ func ParseFlags(cmd string) { os.Exit(0) } + if usePSLogger { + // Replace glog logger with PlanetScale logger + logutil.SetPlanetScaleLogger(nil) + } + args := fs.Args() if len(args) > 0 { _flag.Usage() From 9453797076722693ffc9e922f2dd5618da950d69 Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Tue, 20 Dec 2022 15:23:07 +0100 Subject: [PATCH 05/10] Update the usage test files and replace _ with - for the flag Signed-off-by: Emad Habib --- go/flags/endtoend/mysqlctl.txt | 1 + go/flags/endtoend/mysqlctld.txt | 1 + go/flags/endtoend/vtctld.txt | 1 + go/flags/endtoend/vtgate.txt | 1 + go/flags/endtoend/vtorc.txt | 1 + go/flags/endtoend/vttablet.txt | 1 + go/flags/endtoend/vttestserver.txt | 1 + go/vt/servenv/servenv.go | 2 +- 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/go/flags/endtoend/mysqlctl.txt b/go/flags/endtoend/mysqlctl.txt index f5b810f0dd0..3829c6ff0a6 100644 --- a/go/flags/endtoend/mysqlctl.txt +++ b/go/flags/endtoend/mysqlctl.txt @@ -80,6 +80,7 @@ Global flags: --service_map strings comma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice --socket_file string Local unix socket file to listen on --stderrthreshold severity logs at or above this threshold go to stderr (default 1) + --structured-logging whether to use structured logging (PlanetScale Log) logger or the original (glog) logger --tablet_dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid. --tablet_uid uint Tablet UID (default 41983) --v Level log level for V logs diff --git a/go/flags/endtoend/mysqlctld.txt b/go/flags/endtoend/mysqlctld.txt index 50ec38dab3e..ec58cc21f87 100644 --- a/go/flags/endtoend/mysqlctld.txt +++ b/go/flags/endtoend/mysqlctld.txt @@ -84,6 +84,7 @@ Usage of mysqlctld: --service_map strings comma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice --socket_file string Local unix socket file to listen on --stderrthreshold severity logs at or above this threshold go to stderr (default 1) + --structured-logging whether to use structured logging (PlanetScale Log) logger or the original (glog) logger --tablet_dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid. --tablet_uid uint Tablet UID (default 41983) --v Level log level for V logs diff --git a/go/flags/endtoend/vtctld.txt b/go/flags/endtoend/vtctld.txt index c77614084d8..28778890e84 100644 --- a/go/flags/endtoend/vtctld.txt +++ b/go/flags/endtoend/vtctld.txt @@ -99,6 +99,7 @@ Usage of vtctld: --stats_drop_variables string Variables to be dropped from the list of exported variables. --stats_emit_period duration Interval between emitting stats to all registered backends (default 1m0s) --stderrthreshold severity logs at or above this threshold go to stderr (default 1) + --structured-logging whether to use structured logging (PlanetScale Log) logger or the original (glog) logger --tablet_dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid. --tablet_grpc_ca string the server ca to use to validate servers when connecting --tablet_grpc_cert string the cert to use to connect diff --git a/go/flags/endtoend/vtgate.txt b/go/flags/endtoend/vtgate.txt index b24966b2726..3ea6312348b 100644 --- a/go/flags/endtoend/vtgate.txt +++ b/go/flags/endtoend/vtgate.txt @@ -154,6 +154,7 @@ Usage of vtgate: --statsd_sample_rate float Sample rate for statsd metrics (default 1) --stderrthreshold severity logs at or above this threshold go to stderr (default 1) --stream_buffer_size int 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) + --structured-logging whether to use structured logging (PlanetScale Log) logger or the original (glog) logger --tablet_filters strings Specifies a comma-separated list of 'keyspace|shard_name or keyrange' values to filter the tablets to watch. --tablet_grpc_ca string the server ca to use to validate servers when connecting --tablet_grpc_cert string the cert to use to connect diff --git a/go/flags/endtoend/vtorc.txt b/go/flags/endtoend/vtorc.txt index 254b3fd8331..897e401ecaf 100644 --- a/go/flags/endtoend/vtorc.txt +++ b/go/flags/endtoend/vtorc.txt @@ -51,6 +51,7 @@ Usage of vtorc: --stats_drop_variables string Variables to be dropped from the list of exported variables. --stats_emit_period duration Interval between emitting stats to all registered backends (default 1m0s) --stderrthreshold severity logs at or above this threshold go to stderr (default 1) + --structured-logging whether to use structured logging (PlanetScale Log) logger or the original (glog) logger --tablet_manager_grpc_ca string the server ca to use to validate servers when connecting --tablet_manager_grpc_cert string the cert to use to connect --tablet_manager_grpc_concurrency int concurrency to use to talk to a vttablet server for performance-sensitive RPCs (like ExecuteFetchAs{Dba,AllPrivs,App}) (default 8) diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index ff445a03ddc..de62b975ff6 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -277,6 +277,7 @@ Usage of vttablet: --statsd_sample_rate float Sample rate for statsd metrics (default 1) --stderrthreshold severity logs at or above this threshold go to stderr (default 1) --stream_health_buffer_size uint max streaming health entries to buffer per streaming health client (default 20) + --structured-logging whether to use structured logging (PlanetScale Log) logger or the original (glog) logger --table-acl-config string path to table access checker config file; send SIGHUP to reload this file --table-acl-config-reload-interval duration Ticker to reload ACLs. Duration flag, format e.g.: 30s. Default: do not reload --table_gc_lifecycle string States for a DROP TABLE garbage collection cycle. Default is 'hold,purge,evac,drop', use any subset ('drop' implcitly always included) (default "hold,purge,evac,drop") diff --git a/go/flags/endtoend/vttestserver.txt b/go/flags/endtoend/vttestserver.txt index fbe1c130f70..e1492bfd4ee 100644 --- a/go/flags/endtoend/vttestserver.txt +++ b/go/flags/endtoend/vttestserver.txt @@ -98,6 +98,7 @@ Usage of vttestserver: --sql-max-length-errors int truncate queries in error logs to the given length (default unlimited) --sql-max-length-ui int truncate queries in debug UIs to the given length (default 512) (default 512) --stderrthreshold severity logs at or above this threshold go to stderr (default 1) + --structured-logging whether to use structured logging (PlanetScale Log) logger or the original (glog) logger --tablet_dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid. --tablet_hostname string The hostname to use for the tablet otherwise it will be derived from OS' hostname (default "localhost") --tablet_manager_grpc_ca string the server ca to use to validate servers when connecting diff --git a/go/vt/servenv/servenv.go b/go/vt/servenv/servenv.go index 997e3ede980..30cbf7fb35f 100644 --- a/go/vt/servenv/servenv.go +++ b/go/vt/servenv/servenv.go @@ -100,7 +100,7 @@ func RegisterFlags() { // pid_file.go fs.StringVar(&pidFile, "pid_file", pidFile, "If set, the process will write its pid to the named file, and delete it on graceful shutdown.") // Logging - fs.BoolVar(&usePSLogger, "structure_logging", usePSLogger, "whether to use structure logging (Planet Scale Log) logger or the original (glog) logger") + fs.BoolVar(&usePSLogger, "structured-logging", usePSLogger, "whether to use structured logging (PlanetScale Log) logger or the original (glog) logger") }) } From eb47a09c082d68a52a9db75ce93ff39615c359dc Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Tue, 20 Dec 2022 15:57:58 +0100 Subject: [PATCH 06/10] Apply code review comments Signed-off-by: Emad Habib --- go/vt/logutil/planetscale_logger.go | 25 +++++++++++++++-- go/vt/logutil/planetscale_logger_test.go | 35 +++++++++--------------- go/vt/servenv/servenv.go | 5 +++- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/go/vt/logutil/planetscale_logger.go b/go/vt/logutil/planetscale_logger.go index e58129efb11..2258ad61840 100644 --- a/go/vt/logutil/planetscale_logger.go +++ b/go/vt/logutil/planetscale_logger.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package logutil import ( @@ -9,11 +25,14 @@ import ( type PSLogger pslog.SugaredLogger -// SetPlanetScaleLogger in-place noglog replacement with PlanetScales' logger. -func SetPlanetScaleLogger(conf *pslog.Config) (psLogger *pslog.SugaredLogger) { +// SetPlanetScaleLogger in-place noglog replacement with PlanetScale's logger. +func SetPlanetScaleLogger(conf *pslog.Config) (psLogger *pslog.SugaredLogger, err error) { // Use the passed configuration instead of the default configuration if conf != nil { - configLogger, _ := conf.Build() + configLogger, err := conf.Build() + if err != nil { + return nil, err + } psLogger = configLogger.Sugar() } else { psLogger = pslog.NewPlanetScaleSugarLogger() diff --git a/go/vt/logutil/planetscale_logger_test.go b/go/vt/logutil/planetscale_logger_test.go index 53d7a39c20d..1ed1d21b42f 100644 --- a/go/vt/logutil/planetscale_logger_test.go +++ b/go/vt/logutil/planetscale_logger_test.go @@ -40,7 +40,10 @@ func SetupLoggerWithMemSink() (sink *MemorySink, err error) { testLoggerConf := pslog.NewPlanetScaleConfig(pslog.DetectEncoding(), pslog.InfoLevel) testLoggerConf.OutputPaths = []string{"memory://"} testLoggerConf.ErrorOutputPaths = []string{"memory://"} - SetPlanetScaleLogger(&testLoggerConf) + _, err = SetPlanetScaleLogger(&testLoggerConf) + if err != nil { + return nil, err + } return } @@ -56,7 +59,6 @@ func TestPSLogger_Replacing_glog(t *testing.T) { logLevel zapcore.Level } - // Given dummyLogMessage := "testing log" testCases := []testCase{ {"log info", pslog.InfoLevel}, @@ -65,11 +67,8 @@ func TestPSLogger_Replacing_glog(t *testing.T) { } sink, err := SetupLoggerWithMemSink() - if err != nil { - t.Fatal(err) - } + assert.NoError(t, err) - // When for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { var loggingFunc func(format string, args ...interface{}) @@ -77,33 +76,25 @@ func TestPSLogger_Replacing_glog(t *testing.T) { switch tc.logLevel { case zapcore.InfoLevel: - { - loggingFunc = vtlog.Infof - expectedLevel = "info" - } + loggingFunc = vtlog.Infof + expectedLevel = "info" case zapcore.ErrorLevel: - { - loggingFunc = vtlog.Errorf - expectedLevel = "error" - } + loggingFunc = vtlog.Errorf + expectedLevel = "error" case zapcore.WarnLevel: - { - loggingFunc = vtlog.Warningf - expectedLevel = "warn" - } + loggingFunc = vtlog.Warningf + expectedLevel = "warn" } loggingFunc(dummyLogMessage) + // Unmarshal the captured log. This means we're getting a struct log. actualLog := logMsg{} err = json.Unmarshal(sink.Bytes(), &actualLog) - if err != nil { - t.Error(err) - } + assert.NoError(t, err) // Reset the sink so that it'll contain one log per test case. sink.Reset() - // Then assert.Equal(t, expectedLevel, actualLog.Level) assert.Equal(t, dummyLogMessage, actualLog.Msg) diff --git a/go/vt/servenv/servenv.go b/go/vt/servenv/servenv.go index 30cbf7fb35f..45796d912a0 100644 --- a/go/vt/servenv/servenv.go +++ b/go/vt/servenv/servenv.go @@ -327,7 +327,10 @@ func ParseFlags(cmd string) { if usePSLogger { // Replace glog logger with PlanetScale logger - logutil.SetPlanetScaleLogger(nil) + _, err := logutil.SetPlanetScaleLogger(nil) + if err != nil { + log.Exitf("error while setting the PlanetScale logger: %s", err) + } } args := fs.Args() From 823d7b02c6f1bb088d2690ff633abc075a7e7806 Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Fri, 23 Dec 2022 15:49:38 +0100 Subject: [PATCH 07/10] Add copyrights and release notes Signed-off-by: Emad Habib --- doc/releasenotes/16_0_0_summary.md | 15 +++++++++++++++ go/vt/logutil/planetscale_logger_test.go | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/doc/releasenotes/16_0_0_summary.md b/doc/releasenotes/16_0_0_summary.md index af954e6d0fa..7ab2a5d3ae7 100644 --- a/doc/releasenotes/16_0_0_summary.md +++ b/doc/releasenotes/16_0_0_summary.md @@ -33,6 +33,21 @@ In [PR #11097](https://github.com/vitessio/vitess/pull/11097) we introduced nati - A server restored to a point in time remains in `DRAINED` tablet type, and does not join the replication stream (thus, "frozen" in time). - It is possible to take incremental backups from different tablets. It is OK to have overlaps in incremental backup contents. The restore process chooses a valid path, and is valid as long as there are no gaps in the backed up binary log content. + +### Structured Logging Flag + +In [PR #11960](https://github.com/vitessio/vitess/pull/11960/) we introduced and new flag `structured-logging`. This flag stops the `glog` usage and use [`PlanetScale Log`](https://github.com/planetscale/log) instead. + +The flag is available in these components: + +- mysqlctl +- mysqlctld +- vtctld +- vtgate +- vtorc +- vttablet +- vttestserver + ### Breaking Changes #### Orchestrator Integration Deletion diff --git a/go/vt/logutil/planetscale_logger_test.go b/go/vt/logutil/planetscale_logger_test.go index 1ed1d21b42f..b0b23851615 100644 --- a/go/vt/logutil/planetscale_logger_test.go +++ b/go/vt/logutil/planetscale_logger_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package logutil import ( From 4dcaf169a1fc7c96f485b2feeb566e6a24c776c3 Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Mon, 2 Jan 2023 09:33:35 +0100 Subject: [PATCH 08/10] Update the year in the copyrights Signed-off-by: Emad Habib --- go/vt/logutil/planetscale_logger.go | 2 +- go/vt/logutil/planetscale_logger_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/vt/logutil/planetscale_logger.go b/go/vt/logutil/planetscale_logger.go index 2258ad61840..7133188df4f 100644 --- a/go/vt/logutil/planetscale_logger.go +++ b/go/vt/logutil/planetscale_logger.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Vitess Authors. +Copyright 2023 The Vitess Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/go/vt/logutil/planetscale_logger_test.go b/go/vt/logutil/planetscale_logger_test.go index b0b23851615..9433a0ddca0 100644 --- a/go/vt/logutil/planetscale_logger_test.go +++ b/go/vt/logutil/planetscale_logger_test.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Vitess Authors. +Copyright 2023 The Vitess Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 6d451d441a4b6273f12c71722832265f4f062335 Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Mon, 9 Jan 2023 15:41:56 +0100 Subject: [PATCH 09/10] Fix typo Signed-off-by: Emad Habib --- doc/releasenotes/16_0_0_summary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/releasenotes/16_0_0_summary.md b/doc/releasenotes/16_0_0_summary.md index 7ab2a5d3ae7..51758ac379d 100644 --- a/doc/releasenotes/16_0_0_summary.md +++ b/doc/releasenotes/16_0_0_summary.md @@ -36,7 +36,7 @@ In [PR #11097](https://github.com/vitessio/vitess/pull/11097) we introduced nati ### Structured Logging Flag -In [PR #11960](https://github.com/vitessio/vitess/pull/11960/) we introduced and new flag `structured-logging`. This flag stops the `glog` usage and use [`PlanetScale Log`](https://github.com/planetscale/log) instead. +In [PR #11960](https://github.com/vitessio/vitess/pull/11960/) we introduced a new flag `structured-logging`. This flag stops the `glog` usage and use [`PlanetScale Log`](https://github.com/planetscale/log) instead. The flag is available in these components: From f52977d9396a85def5994286fbcbc5c29fbdc1c7 Mon Sep 17 00:00:00 2001 From: Emad Habib Date: Wed, 11 Jan 2023 10:34:59 +0100 Subject: [PATCH 10/10] Empty Commit Signed-off-by: Emad Habib