in klog.go [618:658]
func (l *loggingT) formatHeader(s severity, file string, line int) *buffer {
now := timeNow()
if line < 0 {
line = 0 // not a real line number, but acceptable to someDigits
}
if s > fatalLog {
s = infoLog // for safety.
}
buf := l.getBuffer()
if l.skipHeaders {
return buf
}
// Avoid Fprintf, for speed. The format is so simple that we can do it quickly by hand.
// It's worth about 3X. Fprintf is hard.
_, month, day := now.Date()
hour, minute, second := now.Clock()
// Lmmdd hh:mm:ss.uuuuuu threadid file:line]
buf.tmp[0] = severityChar[s]
buf.twoDigits(1, int(month))
buf.twoDigits(3, day)
buf.tmp[5] = ' '
buf.twoDigits(6, hour)
buf.tmp[8] = ':'
buf.twoDigits(9, minute)
buf.tmp[11] = ':'
buf.twoDigits(12, second)
buf.tmp[14] = '.'
buf.nDigits(6, 15, now.Nanosecond()/1000, '0')
buf.tmp[21] = ' '
buf.nDigits(7, 22, pid, ' ') // TODO: should be TID
buf.tmp[29] = ' '
buf.Write(buf.tmp[:30])
buf.WriteString(file)
buf.tmp[0] = ':'
n := buf.someDigits(1, line)
buf.tmp[n+1] = ']'
buf.tmp[n+2] = ' '
buf.Write(buf.tmp[:n+3])
return buf
}