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

Allow using planetscale's log instead of glog #19

Conversation

ejortegau
Copy link
Collaborator

@ejortegau ejortegau commented Nov 15, 2022

Description

This can be controlled with a command flag. However, notice that using the planetscale logger means that automatic log rotation does now work, as this is not provided by planetscale's logger or the underlying zap logger, whereas it does come in with glog.

Usual logging continues to work without any changes:

% ./bin/vtgate
F1115 11:53:04.508981   49238 server.go:224] topo_global_server_address must be configured

But with the new flag, it changes to planetscale's logger:

% ./bin/vtgate -log_planetscale
{"level":"info","time":"2022-11-15T11:54:32+01:00","caller":"log/log.go:96","msg":"Version: 12.0.5 (Git revision ebca7e95de branch 'eduardo_ortega_structured_logging') built on Tue Nov 15 10:59:08 CET 2022 by eduardo.ortega@eduardo-ltmnjyh.internal.salesforce.com using go1.18.8 darwin/amd64"}
{"level":"error","time":"2022-11-15T11:54:32+01:00","caller":"log/log.go:98","msg":"topo_global_server_address must be configured","stacktrace":"vitess.io/vitess/go/vt/log.SetPlanetScaleLog.func5\n\tvitess.io/vitess/go/vt/log/log.go:98\ngh.neting.cc/slok/noglog.(*LoggerFunc).Errorf\n\tgh.neting.cc/slok/noglog@v0.2.0/glog.go:210\ngh.neting.cc/slok/noglog.Errorf\n\tgh.neting.cc/slok/noglog@v0.2.0/glog.go:135\ngh.neting.cc/slok/noglog.Exitf\n\tgh.neting.cc/slok/noglog@v0.2.0/glog.go:182\nvitess.io/vitess/go/vt/topo.Open\n\tvitess.io/vitess/go/vt/topo/server.go:224\nmain.main\n\tvitess.io/vitess/go/cmd/vtgate/vtgate.go:116\nruntime.main\n\truntime/proc.go:250"}

Using Planetscale's logger (which under the hood is a wrapper for Uber's zap) together with noglog as in this PR allows for an easy migration path away from glog; while also providing an initial approach to structured logging.

Notice that to get this upstreamed, a different PR with slightly different code changes is necessary, as the way in which the log related CLI flags are registered is different.

Related issue

vitessio#11613

This can be controlled with a command flag. However, notice that using the
planetscale logger means that automatic log rotation does now work, as this is
not provided by planetscale's logger or the underlying zap logger, whereas it
does come in with glog.
@CLAassistant
Copy link

CLAassistant commented Nov 15, 2022

CLA assistant check
All committers have signed the CLA.

@ejortegau ejortegau closed this Nov 17, 2022
@tanjinx tanjinx added the v12 label Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants