改为github的包
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -40,12 +41,16 @@ func (l *Logger) logger(ctx context.Context, event string, v ...any) {
|
|||||||
Content: string(by),
|
Content: string(by),
|
||||||
TraceId: traceId,
|
TraceId: traceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if event == "error" {
|
||||||
|
fd.Stack = string(debug.Stack())
|
||||||
|
}
|
||||||
|
|
||||||
fdb, _ := json.Marshal(fd)
|
fdb, _ := json.Marshal(fd)
|
||||||
|
|
||||||
ff := []byte("\n[" + event + "]")
|
ff := []byte("\n[" + event + "]")
|
||||||
fdb = append(ff, fdb...)
|
fdb = append(ff, fdb...)
|
||||||
|
|
||||||
|
|
||||||
l.write(event, fdb)
|
l.write(event, fdb)
|
||||||
|
|
||||||
if l.option.errorToInfo && event == "error" {
|
if l.option.errorToInfo && event == "error" {
|
||||||
@@ -62,4 +67,5 @@ type FormatData struct {
|
|||||||
Gid string `json:"gid,omitempty"`
|
Gid string `json:"gid,omitempty"`
|
||||||
Content string `json:"content,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
TraceId string `json:"traceId,omitempty"`
|
TraceId string `json:"traceId,omitempty"`
|
||||||
|
Stack string `json:"stack,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module code.yun.ink/pkg/loggerx
|
module github.com/yuninks/loggerx
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
require github.com/gin-gonic/gin v1.9.1
|
require github.com/gin-gonic/gin v1.9.1
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.yun.ink/pkg/loggerx"
|
"github.com/yuninks/loggerx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// func TestMain(m *testing.M) {
|
// func TestMain(m *testing.M) {
|
||||||
|
|||||||
Reference in New Issue
Block a user