Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/store/util/verbose: Add ability to override Log function. #269

Merged
merged 6 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 78 additions & 0 deletions go/Godeps/LICENSES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ require (
github.com/src-d/go-mysql-server v0.4.1-0.20190821121850-0e0249cf7bc0
github.com/stretchr/testify v1.4.0
github.com/tealeg/xlsx v1.0.4-0.20190601071628-e2d23f3c43dc
go.uber.org/zap v1.13.0
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914
golang.org/x/sys v0.0.0-20190926180325-855e68c8590b
Expand Down
23 changes: 23 additions & 0 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPg
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go v0.0.0-20161107002406-da06d194a00e h1:CYRpN206UTHUinz3VJoLaBdy1gEGeJNsqT0mvswDcMw=
Expand Down Expand Up @@ -220,6 +221,7 @@ github.com/liquidata-inc/go-mysql-server v0.4.1-0.20191212021013-69ac22b48557 h1
github.com/liquidata-inc/go-mysql-server v0.4.1-0.20191212021013-69ac22b48557/go.mod h1:DeBpId6VrgpYrmit4j6bjX7LgoNYYp1fmtlQTxOrc/Q=
github.com/liquidata-inc/go-mysql-server v0.4.1-0.20191216220517-d3d3dddf789d h1:+za0TgBG3sY3HPDUVU+9mygF17TVtn32W4wN5EZgaKg=
github.com/liquidata-inc/go-mysql-server v0.4.1-0.20191216220517-d3d3dddf789d/go.mod h1:eieDz4jVcWLnZLlefNZQmmpOcCQ3t7CRZ2oyXO432Wk=
github.com/liquidata-inc/go-mysql-server v0.4.1-0.20191219001415-808771c452f5 h1:Ybv068yF+JhBtVHCKUtkGfA9TBdtlXmElwn9txJrN5E=
github.com/liquidata-inc/go-mysql-server v0.4.1-0.20191219001415-808771c452f5/go.mod h1:eieDz4jVcWLnZLlefNZQmmpOcCQ3t7CRZ2oyXO432Wk=
github.com/liquidata-inc/ishell v0.0.0-20190514193646-693241f1f2a0 h1:phMgajKClMUiIr+hF2LGt8KRuUa2Vd2GI1sNgHgSXoU=
github.com/liquidata-inc/ishell v0.0.0-20190514193646-693241f1f2a0/go.mod h1:YC1rI9k5gx8D02ljlbxDfZe80s/iq8bGvaaQsvR+qxs=
Expand Down Expand Up @@ -303,6 +305,7 @@ github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 h1:YDeskXpkN
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44 h1:XKCbzPvK4/BbMXoMJOkYP2ANxiAEO0HM1xn6psSbXxY=
github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/samuel/go-zookeeper v0.0.0-20160616024954-e64db453f351/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/sanity-io/litter v1.2.0 h1:DGJO0bxH/+C2EukzOSBmAlxmkhVMGqzvcx/rvySYw9M=
github.com/sanity-io/litter v1.2.0/go.mod h1:JF6pZUFgu2Q0sBZ+HSV35P8TVPI1TTzEwyu9FXAw2W4=
Expand Down Expand Up @@ -368,12 +371,21 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.1 h1:8dP3SGL7MPB94crU3bEPplMPe83FI4EouesJUeFHv50=
go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/multierr v1.3.0 h1:sFPn2GLc3poCkfrpIXGhBD2X0CMIo4Q/zSULXrj/+uc=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
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=
golang.org/x/crypto v0.0.0-20190128193316-c7b33c32a30b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM=
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand All @@ -385,7 +397,10 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -449,7 +464,12 @@ golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBn
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
Expand Down Expand Up @@ -483,6 +503,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.41.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ldap.v2 v2.5.0/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk=
gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4=
Expand All @@ -497,6 +518,8 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
modernc.org/mathutil v1.0.0 h1:93vKjrJopTPrtTNpZ8XIovER7iCIH1QU7wNbOQXC60I=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
modernc.org/strutil v1.0.0 h1:XVFtQwFVwc02Wk+0L/Z/zDDXO81r5Lhe6iMKmGX3KhE=
Expand Down
2 changes: 0 additions & 2 deletions go/store/cmd/noms/noms.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func main() {
memProfileVal := noms.Flag("memprofile", "write memory profile to file").String()
blockProfileVal := noms.Flag("blockprofile", "write block profile to file").String()
verboseVal := noms.Flag("verbose", "show more").Short('v').Bool()
quietVal := noms.Flag("quiet", "show less").Short('q').Bool()

// set up docs for non-kingpin commands
addNomsDocs(noms)
Expand All @@ -111,7 +110,6 @@ func main() {
// apply global flags
profile.ApplyProfileFlags(cpuProfileVal, memProfileVal, blockProfileVal)
verbose.SetVerbose(*verboseVal)
verbose.SetQuiet(*quietVal)

if handler := handlers[strings.Split(input, " ")[0]]; handler != nil {
handler(input)
Expand Down
13 changes: 5 additions & 8 deletions go/store/cmd/noms/noms_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ func runMerge(ctx context.Context, args []string) int {
_, err = db.SetHead(ctx, outDS, ref)
d.PanicIfError(err)

if !verbose.Quiet() {
status.Printf("Done")
status.Done()
}
status.Printf("Done")
status.Done()

return 0
}

Expand Down Expand Up @@ -220,10 +219,8 @@ func newMergeProgressChan() chan struct{} {
go func() {
count := 0
for range pc {
if !verbose.Quiet() {
count++
status.Printf("Applied %d changes...", count)
}
count++
status.Printf("Applied %d changes...", count)
}
}()
return pc
Expand Down
12 changes: 6 additions & 6 deletions go/store/config/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ func NewResolver() *Resolver {
}

// Print replacement if one occurred
func (r *Resolver) verbose(orig string, replacement string) string {
func (r *Resolver) verbose(ctx context.Context, orig string, replacement string) string {
if orig != replacement {
if orig == "" {
orig = `""`
}
verbose.Log("\tresolving %s -> %s\n", orig, replacement)
verbose.Logger(ctx).Sugar().Debugf("\tresolving %s -> %s", orig, replacement)
}
return replacement
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func (r *Resolver) ResolvePathSpec(str string) string {
// - resolve "" to the default db spec
func (r *Resolver) GetDatabase(ctx context.Context, str string) (datas.Database, error) {
dbc := r.DbConfigForDbSpec(str)
sp, err := spec.ForDatabaseOpts(r.verbose(str, dbc.Url), specOptsForConfig(r.config, dbc))
sp, err := spec.ForDatabaseOpts(r.verbose(ctx, str, dbc.Url), specOptsForConfig(r.config, dbc))
if err != nil {
return nil, err
}
Expand All @@ -142,7 +142,7 @@ func (r *Resolver) GetDatabase(ctx context.Context, str string) (datas.Database,
// Resolve string to a chunkstore. Like ResolveDatabase, but returns the underlying ChunkStore
func (r *Resolver) GetChunkStore(ctx context.Context, str string) (chunks.ChunkStore, error) {
dbc := r.DbConfigForDbSpec(str)
sp, err := spec.ForDatabaseOpts(r.verbose(str, dbc.Url), specOptsForConfig(r.config, dbc))
sp, err := spec.ForDatabaseOpts(r.verbose(ctx, str, dbc.Url), specOptsForConfig(r.config, dbc))
if err != nil {
return nil, err
}
Expand All @@ -154,7 +154,7 @@ func (r *Resolver) GetChunkStore(ctx context.Context, str string) (chunks.ChunkS
// - if the db prefix is an alias, replace it
func (r *Resolver) GetDataset(ctx context.Context, str string) (datas.Database, datas.Dataset, error) {
specStr, dbc := r.ResolvePathSpecAndGetDbConfig(str)
sp, err := spec.ForDatasetOpts(r.verbose(str, specStr), specOptsForConfig(r.config, dbc))
sp, err := spec.ForDatasetOpts(r.verbose(ctx, str, specStr), specOptsForConfig(r.config, dbc))
if err != nil {
return nil, datas.Dataset{}, err
}
Expand All @@ -166,7 +166,7 @@ func (r *Resolver) GetDataset(ctx context.Context, str string) (datas.Database,
// - if the db spec is an alias, replace it
func (r *Resolver) GetPath(ctx context.Context, str string) (datas.Database, types.Value, error) {
specStr, dbc := r.ResolvePathSpecAndGetDbConfig(str)
sp, err := spec.ForPathOpts(r.verbose(str, specStr), specOptsForConfig(r.config, dbc))
sp, err := spec.ForPathOpts(r.verbose(ctx, str, specStr), specOptsForConfig(r.config, dbc))
if err != nil {
return nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go/store/nbs/aws_table_persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (s3p awsTablePersister) ConjoinAll(ctx context.Context, sources chunkSource
return nil, err
}

verbose.Log("Compacted table of %d Kb in %s", plan.totalCompressedData/1024, time.Since(t1))
verbose.Logger(ctx).Sugar().Debugf("Compacted table of %d Kb in %s", plan.totalCompressedData/1024, time.Since(t1))

if s3p.tc != nil {
go func() {
Expand Down
4 changes: 2 additions & 2 deletions go/store/nbs/dynamo_table_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"context"
"fmt"
"io"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"

"github.com/liquidata-inc/dolt/go/store/util/sizecache"
"github.com/liquidata-inc/dolt/go/store/util/verbose"
)

const (
Expand Down Expand Up @@ -128,7 +128,7 @@ func (dts *ddbTableStore) readTable(ctx context.Context, name addr) (data []byte
}
data, err = try(&input)
if _, isNotFound := err.(tableNotInDynamoErr); isNotFound {
log.Printf("Eventually consistent read for %s failed; trying fully-consistent", name)
verbose.Logger(ctx).Sugar().Debugf("Eventually consistent read for %s failed; trying fully-consistent", name)
input.ConsistentRead = aws.Bool(true)
return try(&input)
}
Expand Down
43 changes: 21 additions & 22 deletions go/store/util/verbose/verbose.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
package verbose

import (
"log"
"context"
"os"

flag "github.com/juju/gnuflag"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

var (
Expand All @@ -36,35 +39,31 @@ var (
func RegisterVerboseFlags(flags *flag.FlagSet) {
flags.BoolVar(&verbose, "verbose", false, "show more")
flags.BoolVar(&verbose, "v", false, "")
flags.BoolVar(&quiet, "quiet", false, "show less")
flags.BoolVar(&quiet, "q", false, "")
}

// Verbose returns True if the verbose flag was set
func Verbose() bool {
return verbose
}

func SetVerbose(v bool) {
verbose = v
}

// Quiet returns True if the verbose flag was set
func Quiet() bool {
return quiet
}

func SetQuiet(q bool) {
quiet = q
}
// A function which will be called for logging throughout the doltcore/store
// layer. Defaults to logging to STDERR at Debug level if --verbose is set and
// Warn level if --verbose is not set.
//
// May be called with `nil` context in non-context-aware functions.
var Logger func(ctx context.Context) *zap.Logger

// Log calls Printf(format, args...) iff Verbose() returns true.
func Log(format string, args ...interface{}) {
if Verbose() {
if len(args) > 0 {
log.Printf(format+"\n", args...)
func init() {
enabler := zap.LevelEnablerFunc(func(l zapcore.Level) bool {
if verbose {
return zapcore.DebugLevel.Enabled(l)
} else {
log.Println(format)
return zapcore.WarnLevel.Enabled(l)
}
})
encoder := zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig())
core := zapcore.NewCore(encoder, zapcore.Lock(os.Stderr), enabler)
l := zap.New(core)
Logger = func(ctx context.Context) *zap.Logger {
return l
}
}