Skip to content

Commit d36eef7

Browse files
committed
maintner: log about loading unknown JSON only in verbose mode
We already log about storing unknown JSON (on the server) and can look up occurrences there. Most clients don't care, so only log if they are in verbose mode. Fixes golang/go#46180. Change-Id: I665511e3d69827108bf59ddcd5e44359cacbaaa2 Reviewed-on: https://go-review.googlesource.com/c/build/+/320290 Trust: Dmitri Shuralyov <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]> Run-TryBot: Alexander Rakoczy <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]>
1 parent 39f255e commit d36eef7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

maintner/github.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ func (g *GitHubRepo) getOrCreateLabel(id int64) *GitHubLabel {
222222
return lb
223223
}
224224

225+
func (g *GitHubRepo) verbose() bool {
226+
return g.github != nil && g.github.c != nil && g.github.c.verbose
227+
}
228+
225229
// GitHubUser represents a GitHub user.
226230
// It is a subset of https://developer.github.com/v3/users/#get-a-single-user
227231
type GitHubUser struct {
@@ -550,7 +554,9 @@ func (r *GitHubRepo) newGithubReview(p *maintpb.GithubReview) *GitHubReview {
550554
if len(p.OtherJson) > 0 {
551555
// TODO: parse it and see if we've since learned how
552556
// to deal with it?
553-
log.Printf("Unknown JSON in log: %s", p.OtherJson)
557+
if r.verbose() {
558+
log.Printf("newGithubReview: unknown JSON in log: %s", p.OtherJson)
559+
}
554560
e.OtherJSON = string(p.OtherJson)
555561
}
556562

@@ -702,7 +708,9 @@ func (r *GitHubRepo) newGithubEvent(p *maintpb.GithubIssueEvent) *GitHubIssueEve
702708
if len(p.OtherJson) > 0 {
703709
// TODO: parse it and see if we've since learned how
704710
// to deal with it?
705-
log.Printf("Unknown JSON in log: %s", p.OtherJson)
711+
if r.verbose() {
712+
log.Printf("newGithubEvent: unknown JSON in log: %s", p.OtherJson)
713+
}
706714
e.OtherJSON = string(p.OtherJson)
707715
}
708716
if p.Label != nil {
@@ -985,10 +993,6 @@ type githubIssueDiffer struct {
985993
b *github.Issue // may NOT be nil
986994
}
987995

988-
func (d githubIssueDiffer) verbose() bool {
989-
return d.gr.github != nil && d.gr.github.c != nil && d.gr.github.c.verbose
990-
}
991-
992996
// returns nil if no changes.
993997
func (d githubIssueDiffer) Diff() *maintpb.GithubIssueMutation {
994998
var changed bool
@@ -1000,7 +1004,7 @@ func (d githubIssueDiffer) Diff() *maintpb.GithubIssueMutation {
10001004
}
10011005
for _, f := range issueDiffMethods {
10021006
if f(d, m) {
1003-
if d.verbose() {
1007+
if d.gr.verbose() {
10041008
fname := strings.TrimPrefix(runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name(), "golang.org/x/build/maintner.githubIssueDiffer.")
10051009
log.Printf("Issue %d changed: %v", d.b.GetNumber(), fname)
10061010
}

0 commit comments

Comments
 (0)