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