Skip to content

Commit 7557d0d

Browse files
committed
chore: quick update fix/version at 2025-10-22 09:56:19
1 parent 4b2de87 commit 7557d0d

File tree

9 files changed

+501
-23
lines changed

9 files changed

+501
-23
lines changed

assert/aaa.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
package assert
22

3+
import "github.com/pubgo/funk/v2/features"
4+
35
const Name = "assert"
6+
7+
var FeatureDebugMode = features.Bool("assert.debug_mode", false, "debug mode, pretty stack and error")

assert/must_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func init1Next() (err error) {
5757
return nil
5858
}
5959

60+
func TestDebugMode(t *testing.T) {
61+
assert1.Exit(assert1.FeatureDebugMode.Set("true"))
62+
assert1.Must(fmt.Errorf("test next"))
63+
}
64+
6065
func BenchmarkNoPanic(b *testing.B) {
6166
for i := 0; i < b.N; i++ {
6267
_ = func() (err error) {

assert/util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ func must(err error, messageArgs ...any) {
7777
}
7878

7979
logErr(err, message, attrs...)
80+
81+
if FeatureDebugMode.GetValue() {
82+
_, _ = pp.Println(err)
83+
debug.PrintStack()
84+
}
85+
8086
panic(err)
8187
}
8288

errors/aaa.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package errors
22

33
import (
44
"github.com/pubgo/funk/v2/errors/errinter"
5-
"golang.org/x/xerrors"
65
)
76

87
type Maps = errinter.Maps
@@ -14,7 +13,3 @@ type ErrUnwrap = errinter.ErrUnwrap
1413
type Error = errinter.Error
1514
type ErrorProto = errinter.ErrorProto
1615
type GRPCStatus = errinter.GRPCStatus
17-
18-
var (
19-
Opaque = xerrors.Opaque
20-
)

errors/errors.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/rs/xid"
99
"github.com/samber/lo"
10-
"golang.org/x/xerrors"
1110
"google.golang.org/protobuf/proto"
1211
"google.golang.org/protobuf/types/known/anypb"
1312

@@ -28,17 +27,6 @@ func New(msg string, tags ...Tag) error {
2827
return WrapCaller(&Err{Msg: msg, id: xid.New().String(), Tags: tags}, 1)
2928
}
3029

31-
func XErrorf(msg string, args ...interface{}) error {
32-
err := xerrors.Errorf(msg, args)
33-
return &ErrMsg{
34-
err: WrapCaller(err, 1),
35-
pb: &errorpb.ErrMsg{
36-
Id: lo.ToPtr(getErrorId(err)),
37-
Msg: fmt.Sprintf("%v", err),
38-
},
39-
}
40-
}
41-
4230
func Errorf(msg string, args ...interface{}) error {
4331
return WrapCaller(&Err{Msg: fmt.Sprintf(msg, args...), id: xid.New().String()}, 1)
4432
}

log/impl.log.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,24 @@ func (l *loggerImpl) getLog() *zerolog.Logger {
213213
}
214214

215215
func (l *loggerImpl) newEvent(ctx context.Context, e *zerolog.Event) *zerolog.Event {
216-
if l.name != "" {
217-
e = e.Str(logfields.Logger, l.name)
216+
name := l.name
217+
if m, ok := l.fields[logfields.Module].(string); ok {
218+
name = m
219+
}
220+
221+
if name != "" {
222+
e = e.Str(logfields.Logger, name)
218223
}
219224

220225
if l.callerSkip != 0 {
221226
e = e.CallerSkipFrame(l.callerSkip)
222227
}
223228

224-
if l.fields != nil && len(l.fields) > 0 {
229+
if len(l.fields) > 0 {
225230
e = e.Fields(l.fields)
226231
}
227232

228-
e = e.Ctx(createFieldCtx(ctx, &fieldMap{name: l.name, fields: l.fields}))
233+
e = e.Ctx(createFieldCtx(ctx, &fieldMap{name: name, fields: l.fields}))
229234

230235
return mergeEvent(e, getEventFromCtx(ctx), l.content)
231236
}

proto/cloudevent/options.pb.go

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)