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

log: fix staticcheck warnings #20388

Merged
merged 1 commit into from
Nov 28, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions log/handler_glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,21 @@ func (h *GlogHandler) Log(r *Record) error {
}
// Check callsite cache for previously calculated log levels
h.lock.RLock()
lvl, ok := h.siteCache[r.Call.PC()]
lvl, ok := h.siteCache[r.Call.Frame().PC]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you paste what the original errors were here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log/handler_glog.go:210:25: r.Call.PC is deprecated: Use Call.Frame instead.  (SA1019)
log/handler_glog.go:218:17: r.Call.PC is deprecated: Use Call.Frame instead.  (SA1019)
log/handler_glog.go:224:16: r.Call.PC is deprecated: Use Call.Frame instead.  (SA1019)
log/logger.go:86:30: error strings should not be capitalized (ST1005)

h.lock.RUnlock()

// If we didn't cache the callsite yet, calculate it
if !ok {
h.lock.Lock()
for _, rule := range h.patterns {
if rule.pattern.MatchString(fmt.Sprintf("%+s", r.Call)) {
h.siteCache[r.Call.PC()], lvl, ok = rule.level, rule.level, true
h.siteCache[r.Call.Frame().PC], lvl, ok = rule.level, rule.level, true
break
}
}
// If no rule matched, remember to drop log the next time
if !ok {
h.siteCache[r.Call.PC()] = 0
h.siteCache[r.Call.Frame().PC] = 0
}
h.lock.Unlock()
}
Expand Down
2 changes: 1 addition & 1 deletion log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func LvlFromString(lvlString string) (Lvl, error) {
case "crit":
return LvlCrit, nil
default:
return LvlDebug, fmt.Errorf("Unknown level: %v", lvlString)
return LvlDebug, fmt.Errorf("unknown level: %v", lvlString)
}
}

Expand Down