mirror of
https://github.com/beego/bee.git
synced 2025-07-11 02:51:02 +00:00
Fixes the filename and lineNo in debug log message
This commit is contained in:

committed by
Faissal Elamraoui

parent
c3c264ddb5
commit
deacdaa667
15
logger.go
15
logger.go
@ -19,7 +19,6 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"text/template"
|
||||
@ -155,7 +154,7 @@ func (l *BeeLogger) mustLog(level int, message string, args ...interface{}) {
|
||||
|
||||
// mustLogDebug logs a debug message only if debug mode
|
||||
// is enabled. i.e. DEBUG_ENABLED="1"
|
||||
func (l *BeeLogger) mustLogDebug(message string, args ...interface{}) {
|
||||
func (l *BeeLogger) mustLogDebug(message string, file string, line int, args ...interface{}) {
|
||||
if !IsDebugEnabled() {
|
||||
return
|
||||
}
|
||||
@ -163,9 +162,7 @@ func (l *BeeLogger) mustLogDebug(message string, args ...interface{}) {
|
||||
// Change the output to Stderr
|
||||
l.SetOutput(os.Stderr)
|
||||
|
||||
// Create the log record and Get the filename
|
||||
// and the line number of the caller
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
// Create the log record
|
||||
record := LogRecord{
|
||||
ID: fmt.Sprintf("%04d", atomic.AddUint64(&sequenceNo, 1)),
|
||||
Level: l.getColorLevel(levelDebug),
|
||||
@ -178,13 +175,13 @@ func (l *BeeLogger) mustLogDebug(message string, args ...interface{}) {
|
||||
}
|
||||
|
||||
// Debug outputs a debug log message
|
||||
func (l *BeeLogger) Debug(message string) {
|
||||
l.mustLogDebug(message)
|
||||
func (l *BeeLogger) Debug(message string, file string, line int) {
|
||||
l.mustLogDebug(message, file, line)
|
||||
}
|
||||
|
||||
// Debugf outputs a formatted debug log message
|
||||
func (l *BeeLogger) Debugf(message string, vars ...interface{}) {
|
||||
l.mustLogDebug(message, vars...)
|
||||
func (l *BeeLogger) Debugf(message string, file string, line int, vars ...interface{}) {
|
||||
l.mustLogDebug(message, file, line, vars...)
|
||||
}
|
||||
|
||||
// Info outputs an information log message
|
||||
|
Reference in New Issue
Block a user