chore: init bj_power monorepo (dashboard/mes/wms/wms_client/workstation), clear subproject git metadata and align naming to folder names
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type EntLogger struct {
|
||||
*slog.Logger
|
||||
}
|
||||
|
||||
func (l *EntLogger) DebugWithContext(ctx context.Context, v ...any) {
|
||||
var pcs [1]uintptr
|
||||
// skip [runtime.Callers, this function, this function's caller]
|
||||
|
||||
var pc uintptr
|
||||
for i := 6; i < 20; i++ {
|
||||
runtime.Callers(i, pcs[:])
|
||||
frames := runtime.CallersFrames(pcs[:])
|
||||
frame, _ := frames.Next()
|
||||
//fmt.Println(i, frame.Function, frame.File, frame.Line)
|
||||
if !strings.Contains(frame.File, "automatic_changer/ent") && !strings.Contains(frame.File, "entgo.io") {
|
||||
pc = pcs[0]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
r := slog.NewRecord(time.Now(), slog.LevelDebug, fmt.Sprint(v...), pc)
|
||||
/*var attrs []slog.Attr
|
||||
spanCtx := sdktrace.SpanContextFromContext(ctx)
|
||||
if spanCtx.HasTraceID() {
|
||||
attrs = append(attrs, slog.String("trace", spanCtx.TraceID().String()))
|
||||
}
|
||||
if spanCtx.HasSpanID() {
|
||||
attrs = append(attrs, slog.String("span", spanCtx.SpanID().String()))
|
||||
}
|
||||
r.AddAttrs(attrs...)
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}*/
|
||||
_ = l.Handler().Handle(ctx, r)
|
||||
}
|
||||
Reference in New Issue
Block a user