Skip to content

Commit ebf3cf8

Browse files
committed
logger/glog: fix go vet issues
logging.printf triggered a format string warning. Silence it by renaming the function.
1 parent 24cdac4 commit ebf3cf8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

logger/glog/glog.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ func (l *loggingT) printDepth(s severity, depth int, args ...interface{}) {
698698
l.output(s, buf, file, line, false)
699699
}
700700

701-
func (l *loggingT) printf(s severity, format string, args ...interface{}) {
701+
func (l *loggingT) printfmt(s severity, format string, args ...interface{}) {
702702
buf, file, line := l.header(s, 0)
703703
fmt.Fprintf(buf, format, args...)
704704
if buf.Bytes()[buf.Len()-1] != '\n' {
@@ -1088,7 +1088,7 @@ func (v Verbose) Infoln(args ...interface{}) {
10881088
// See the documentation of V for usage.
10891089
func (v Verbose) Infof(format string, args ...interface{}) {
10901090
if v {
1091-
logging.printf(infoLog, format, args...)
1091+
logging.printfmt(infoLog, format, args...)
10921092
}
10931093
}
10941094

@@ -1107,13 +1107,13 @@ func InfoDepth(depth int, args ...interface{}) {
11071107
// Infoln logs to the INFO log.
11081108
// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
11091109
func Infoln(args ...interface{}) {
1110-
logging.println(infoLog, args...)
1110+
logging.print(infoLog, args...)
11111111
}
11121112

11131113
// Infof logs to the INFO log.
11141114
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
11151115
func Infof(format string, args ...interface{}) {
1116-
logging.printf(infoLog, format, args...)
1116+
logging.printfmt(infoLog, format, args...)
11171117
}
11181118

11191119
// Warning logs to the WARNING and INFO logs.
@@ -1137,7 +1137,7 @@ func Warningln(args ...interface{}) {
11371137
// Warningf logs to the WARNING and INFO logs.
11381138
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
11391139
func Warningf(format string, args ...interface{}) {
1140-
logging.printf(warningLog, format, args...)
1140+
logging.printfmt(warningLog, format, args...)
11411141
}
11421142

11431143
// Error logs to the ERROR, WARNING, and INFO logs.
@@ -1161,7 +1161,7 @@ func Errorln(args ...interface{}) {
11611161
// Errorf logs to the ERROR, WARNING, and INFO logs.
11621162
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
11631163
func Errorf(format string, args ...interface{}) {
1164-
logging.printf(errorLog, format, args...)
1164+
logging.printfmt(errorLog, format, args...)
11651165
}
11661166

11671167
// Fatal logs to the FATAL, ERROR, WARNING, and INFO logs,
@@ -1188,7 +1188,7 @@ func Fatalln(args ...interface{}) {
11881188
// including a stack trace of all running goroutines, then calls os.Exit(255).
11891189
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
11901190
func Fatalf(format string, args ...interface{}) {
1191-
logging.printf(fatalLog, format, args...)
1191+
logging.printfmt(fatalLog, format, args...)
11921192
}
11931193

11941194
// fatalNoStacks is non-zero if we are to exit without dumping goroutine stacks.
@@ -1219,5 +1219,5 @@ func Exitln(args ...interface{}) {
12191219
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
12201220
func Exitf(format string, args ...interface{}) {
12211221
atomic.StoreUint32(&fatalNoStacks, 1)
1222-
logging.printf(fatalLog, format, args...)
1222+
logging.printfmt(fatalLog, format, args...)
12231223
}

logger/glog/glog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func TestCompileModulePattern(t *testing.T) {
300300
for _, test := range patternTests {
301301
re, err := compileModulePattern(test.input)
302302
if err != nil {
303-
t.Fatalf("%s: %v", err)
303+
t.Fatalf("%s: %v", test.input, err)
304304
}
305305
if re.String() != test.want {
306306
t.Errorf("mismatch for %q: got %q, want %q", test.input, re.String(), test.want)

0 commit comments

Comments
 (0)