diff --git a/format.go b/format.go index 5e78085..1747b85 100644 --- a/format.go +++ b/format.go @@ -32,6 +32,12 @@ func (l *Logger) logger(ctx context.Context, event string, v ...any) { // writeStr := "[" + event + "]" + nowTime + " " + file + ":" + fmt.Sprintf("%d", line) + " " + funcName + " gid:" + getGID() + " " + traceId + " @data@: " + string(by) + "\n\n" + for idx,val := range v { + if _, ok := val.(error); ok { + v[idx] = fmt.Sprintf("%+v", val) + } + } + fd := FormatData{ Time: nowTime, File: file + ":" + fmt.Sprintf("%d", line), diff --git a/loggerx_test.go b/loggerx_test.go index 27d6c81..ba95cfd 100644 --- a/loggerx_test.go +++ b/loggerx_test.go @@ -3,6 +3,7 @@ package loggerx_test import ( "bytes" "context" + "errors" "fmt" "testing" "time" @@ -38,6 +39,14 @@ func TestLogger(t *testing.T) { time.Sleep(time.Second * 5) } +func TestLogger2(t *testing.T) { + + err := errors.New("test error") + loggerx.Info(context.Background(), err) + +} + + type Print struct { }