From 0e54238559098c8c960193d4416b16ad7590c156 Mon Sep 17 00:00:00 2001 From: Faissal Elamraoui Date: Sun, 13 Nov 2016 15:06:34 +0100 Subject: [PATCH] Included leading zeros for the log record ID --- logger.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/logger.go b/logger.go index 567b073..290264b 100644 --- a/logger.go +++ b/logger.go @@ -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,