Add file/line/function to debug messages

This commit is contained in:
Ettore Di Giacinto
2021-01-22 11:53:50 +01:00
parent 485b8d8c89
commit 161b5f40f7

View File

@@ -3,7 +3,9 @@ package logger
import (
"fmt"
"os"
"path"
"regexp"
"runtime"
"strings"
. "github.com/mudler/luet/pkg/config"
@@ -228,6 +230,11 @@ func Warning(mess ...interface{}) {
}
func Debug(mess ...interface{}) {
pc, file, line, ok := runtime.Caller(1)
if ok {
mess = append([]interface{}{fmt.Sprintf("DEBUG (%s:#%d:%v)",
path.Base(file), line, runtime.FuncForPC(pc).Name())}, mess...)
}
msg("debug", false, mess...)
}