1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 10:10:53 +00:00

Included leading zeros for the log record ID

This commit is contained in:
Faissal Elamraoui 2016-11-13 15:06:34 +01:00
parent cb47cd011c
commit 0e54238559

View File

@ -52,7 +52,7 @@ type BeeLogger struct {
// LogRecord represents a log record and contains the timestamp when the record
// was created, an increasing id, level and the actual formatted log line.
type LogRecord struct {
ID uint64
ID string
Level string
Message string
Filename string
@ -144,7 +144,7 @@ func (l *BeeLogger) getColorLevel(level int) string {
func (l *BeeLogger) mustLog(level int, message string, args ...interface{}) {
// Create the logging record and pass into the output
record := LogRecord{
ID: atomic.AddUint64(&sequenceNo, 1),
ID: fmt.Sprintf("%04d", atomic.AddUint64(&sequenceNo, 1)),
Level: l.getColorLevel(level),
Message: fmt.Sprintf(message, args...),
}
@ -167,7 +167,7 @@ func (l *BeeLogger) mustLogDebug(message string, args ...interface{}) {
// and the line number of the caller
_, file, line, _ := runtime.Caller(1)
record := LogRecord{
ID: atomic.AddUint64(&sequenceNo, 1),
ID: fmt.Sprintf("%04d", atomic.AddUint64(&sequenceNo, 1)),
Level: l.getColorLevel(levelDebug),
Message: fmt.Sprintf(message, args...),
LineNo: line,