Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Oct 24, 2024
1 parent 0f015c9 commit 4353e1b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 35 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require (
github.com/evanphx/json-patch v5.9.0+incompatible
github.com/fsnotify/fsnotify v1.7.0
github.com/go-sql-driver/mysql v1.7.1
github.com/golang/glog v1.2.2
github.com/golang/protobuf v1.5.4
github.com/golang/snappy v0.0.4
github.com/google/go-cmp v0.6.0
Expand Down Expand Up @@ -107,6 +106,7 @@ require (
github.com/spf13/jwalterweatherman v1.1.0
github.com/xlab/treeprint v1.2.0
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/sync v0.8.0
gonum.org/v1/gonum v0.14.0
Expand Down Expand Up @@ -200,7 +200,6 @@ require (
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
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/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY=
github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down
73 changes: 42 additions & 31 deletions go/vt/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,74 @@ package log

import (
"fmt"
"strconv"
"sync/atomic"
"os"
//"strconv"
//"sync/atomic"

"github.com/golang/glog"
"github.com/spf13/pflag"
//"github.com/spf13/pflag"
"go.uber.org/zap"
)

// Level is used with V() to test log verbosity.
type Level = glog.Level
var logger *zap.SugaredLogger

var (
// V quickly checks if the logging verbosity meets a threshold.
V = glog.V
func init() {
logCfg := zap.NewProductionConfig()
lz, err := logCfg.Build()
if err != nil {
fmt.Printf("failed to configure logger: %+v", err)
os.Exit(1)
}
logger = lz.Sugar()
}

var (
// Flush ensures any pending I/O is written.
Flush = glog.Flush
Flush = func() {
_ = logger.Sync()
return
}
Sync = logger.Sync

// Debug formats arguments like fmt.Print.
Debug = logger.Debug
// Debugf formats arguments like fmt.Printf.
Debugf = logger.Debugf

// Info formats arguments like fmt.Print.
Info = glog.Info
Info = logger.Info
// Infof formats arguments like fmt.Printf.
Infof = glog.Infof
// InfoDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
InfoDepth = glog.InfoDepth
Infof = logger.Infof

// Warn formats arguments like fmt.Print.
Warn = logger.Warn
// Warnf formats arguments like fmt.Printf.
Warnf = logger.Warnf
// Warning formats arguments like fmt.Print.
Warning = glog.Warning
Warning = logger.Warn
// Warningf formats arguments like fmt.Printf.
Warningf = glog.Warningf
// WarningDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
WarningDepth = glog.WarningDepth
Warningf = logger.Warnf

// Error formats arguments like fmt.Print.
Error = glog.Error
Error = logger.Error
// Errorf formats arguments like fmt.Printf.
Errorf = glog.Errorf
// ErrorDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
ErrorDepth = glog.ErrorDepth
Errorf = logger.Errorf

// Exit formats arguments like fmt.Print.
Exit = glog.Exit
Exit = logger.Fatal
// Exitf formats arguments like fmt.Printf.
Exitf = glog.Exitf
// ExitDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
ExitDepth = glog.ExitDepth

Exitf = logger.Fatalf
// Fatal formats arguments like fmt.Print.
Fatal = glog.Fatal
Fatal = logger.Fatal
// Fatalf formats arguments like fmt.Printf
Fatalf = glog.Fatalf
// FatalDepth formats arguments like fmt.Print and uses depth to choose which call frame to log.
FatalDepth = glog.FatalDepth
Fatalf = logger.Fatalf
)

// RegisterFlags installs log flags on the given FlagSet.
//
// `go/cmd/*` entrypoints should either use servenv.ParseFlags(WithArgs)? which
// calls this function, or call this function directly before parsing
// command-line arguments.
/*
func RegisterFlags(fs *pflag.FlagSet) {
flagVal := logRotateMaxSize{
val: fmt.Sprintf("%d", atomic.LoadUint64(&glog.MaxSize)),
Expand Down Expand Up @@ -111,3 +121,4 @@ func (lrms *logRotateMaxSize) String() string {
func (lrms *logRotateMaxSize) Type() string {
return "uint64"
}
*/

0 comments on commit 4353e1b

Please sign in to comment.