Skip to content

Commit

Permalink
logger/glog: fix go vet issues
Browse files Browse the repository at this point in the history
logging.printf triggered a format string warning. Silence it
by renaming the function.
  • Loading branch information
fjl committed Apr 15, 2016
1 parent 24cdac4 commit ebf3cf8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions logger/glog/glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ func (l *loggingT) printDepth(s severity, depth int, args ...interface{}) {
l.output(s, buf, file, line, false)
}

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

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

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

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

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

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

// fatalNoStacks is non-zero if we are to exit without dumping goroutine stacks.
Expand Down Expand Up @@ -1219,5 +1219,5 @@ func Exitln(args ...interface{}) {
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Exitf(format string, args ...interface{}) {
atomic.StoreUint32(&fatalNoStacks, 1)
logging.printf(fatalLog, format, args...)
logging.printfmt(fatalLog, format, args...)
}
2 changes: 1 addition & 1 deletion logger/glog/glog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestCompileModulePattern(t *testing.T) {
for _, test := range patternTests {
re, err := compileModulePattern(test.input)
if err != nil {
t.Fatalf("%s: %v", err)
t.Fatalf("%s: %v", test.input, err)
}
if re.String() != test.want {
t.Errorf("mismatch for %q: got %q, want %q", test.input, re.String(), test.want)
Expand Down

0 comments on commit ebf3cf8

Please sign in to comment.