Skip to content

Commit e4f5575

Browse files
lvan100lianghuan
authored andcommitted
refactor(log): update log tag
1 parent 73d1495 commit e4f5575

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module github.com/go-spring/spring-core
33
go 1.24
44

55
require (
6-
github.com/expr-lang/expr v1.17.2
6+
github.com/expr-lang/expr v1.17.5
77
github.com/go-spring/gs-assert v1.0.2
88
github.com/go-spring/gs-mock v0.0.4
9-
github.com/go-spring/log v0.0.3
9+
github.com/go-spring/log v0.0.4
1010
github.com/magiconair/properties v1.8.10
1111
github.com/pelletier/go-toml v1.9.5
12-
github.com/spf13/cast v1.7.1
12+
github.com/spf13/cast v1.9.2
1313
gopkg.in/yaml.v2 v2.4.0
1414
)

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
github.com/expr-lang/expr v1.17.2 h1:o0A99O/Px+/DTjEnQiodAgOIK9PPxL8DtXhBRKC+Iso=
2-
github.com/expr-lang/expr v1.17.2/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
1+
github.com/expr-lang/expr v1.17.5 h1:i1WrMvcdLF249nSNlpQZN1S6NXuW9WaOfF5tPi3aw3k=
2+
github.com/expr-lang/expr v1.17.5/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
33
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
44
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
55
github.com/go-spring/gs-assert v1.0.2 h1:9vDppl7ZwMvQE4c83ac7GzN0VxZC5BrQue7dND7NclQ=
66
github.com/go-spring/gs-assert v1.0.2/go.mod h1:FfibkqWz4HUBpbig1cKMlzW8Ha7RywTB93f1Q/NuF9I=
77
github.com/go-spring/gs-mock v0.0.4 h1:f34YN+ntXflfn13aLa3ZVCB78IG7wWZGK4y5tB+OGpI=
88
github.com/go-spring/gs-mock v0.0.4/go.mod h1:QK0PqZ+Vu9F+BU97zl8fip5XKibvDSoN+ofky413Z6Q=
9-
github.com/go-spring/log v0.0.3 h1:hse6P3RpbQ6GKOB0nnQAvtEusFC1kdkfebdjv3p6O+g=
10-
github.com/go-spring/log v0.0.3/go.mod h1:9SWgPEVWSGgloRTGR7niBliqfwC5UCjPUOl2jyJOimM=
9+
github.com/go-spring/log v0.0.4 h1:gmYPCBt9jH8k5FsbS7WvICiK1aN9mEqXwz2XNvGxKfQ=
10+
github.com/go-spring/log v0.0.4/go.mod h1:9SWgPEVWSGgloRTGR7niBliqfwC5UCjPUOl2jyJOimM=
1111
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
1212
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1313
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@@ -20,8 +20,8 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v
2020
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
2121
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
2222
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
23-
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
24-
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
23+
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
24+
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
2525
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2626
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2727
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=

gs/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *AppStarter) RunWith(fn func(ctx context.Context) error) {
4848
var err error
4949
defer func() {
5050
if err != nil {
51-
log.Errorf(context.Background(), log.TagApp, "app run failed: %v", err)
51+
log.Errorf(context.Background(), log.TagAppDef, "app run failed: %v", err)
5252
}
5353
}()
5454
if err = s.initApp(); err != nil {

gs/gs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func BeanSelectorFor[T any](name ...string) BeanSelector {
173173
// Property sets a system property.
174174
func Property(key string, val string) {
175175
if err := gs_conf.SysConf.Set(key, val); err != nil {
176-
log.Errorf(context.Background(), log.TagApp, "failed to set property key=%s, err=%v", key, err)
176+
log.Errorf(context.Background(), log.TagAppDef, "failed to set property key=%s, err=%v", key, err)
177177
}
178178
}
179179

gs/internal/gs_app/app.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (app *App) RunWith(fn func(ctx context.Context) error) error {
9797
ch := make(chan os.Signal, 1)
9898
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
9999
sig := <-ch
100-
log.Infof(context.Background(), log.TagApp, "Received signal: %v", sig)
100+
log.Infof(context.Background(), log.TagAppDef, "Received signal: %v", sig)
101101
app.ShutDown()
102102
}()
103103

@@ -145,7 +145,7 @@ func (app *App) Start() error {
145145
}
146146
}()
147147
if err := job.Run(app.ctx); err != nil {
148-
log.Errorf(context.Background(), log.TagApp, "job run error: %v", err)
148+
log.Errorf(context.Background(), log.TagAppDef, "job run error: %v", err)
149149
app.ShutDown()
150150
}
151151
})
@@ -169,7 +169,7 @@ func (app *App) Start() error {
169169
}()
170170
err := svr.ListenAndServe(sig)
171171
if err != nil && !errors.Is(err, http.ErrServerClosed) {
172-
log.Errorf(context.Background(), log.TagApp, "server serve error: %v", err)
172+
log.Errorf(context.Background(), log.TagAppDef, "server serve error: %v", err)
173173
sig.Intercept()
174174
app.ShutDown()
175175
}
@@ -179,7 +179,7 @@ func (app *App) Start() error {
179179
if sig.Intercepted() {
180180
return nil
181181
}
182-
log.Infof(context.Background(), log.TagApp, "ready to serve requests")
182+
log.Infof(context.Background(), log.TagAppDef, "ready to serve requests")
183183
sig.Close()
184184
}
185185
return nil
@@ -196,7 +196,7 @@ func (app *App) Stop() {
196196
for _, svr := range app.Servers {
197197
goutil.GoFunc(func() {
198198
if err := svr.Shutdown(ctx); err != nil {
199-
log.Errorf(context.Background(), log.TagApp, "shutdown server failed: %v", err)
199+
log.Errorf(context.Background(), log.TagAppDef, "shutdown server failed: %v", err)
200200
}
201201
})
202202
}
@@ -207,9 +207,9 @@ func (app *App) Stop() {
207207

208208
select {
209209
case <-waitChan:
210-
log.Infof(context.Background(), log.TagApp, "shutdown complete")
210+
log.Infof(context.Background(), log.TagAppDef, "shutdown complete")
211211
case <-ctx.Done():
212-
log.Infof(context.Background(), log.TagApp, "shutdown timeout")
212+
log.Infof(context.Background(), log.TagAppDef, "shutdown timeout")
213213
}
214214
}
215215

gs/internal/gs_app/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var logBuf = &bytes.Buffer{}
3939

4040
func init() {
4141
goutil.OnPanic = func(ctx context.Context, r any) {
42-
log.Panicf(ctx, log.TagDef, "panic: %v\n%s\n", r, debug.Stack())
42+
log.Panicf(ctx, log.TagAppDef, "panic: %v\n%s\n", r, debug.Stack())
4343
}
4444
}
4545

gs/internal/gs_core/injecting/injecting.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *Injecting) Refresh(beans []*gs_bean.BeanDefinition) (err error) {
9999
defer func() {
100100
if err != nil || len(stack.beans) > 0 {
101101
err = fmt.Errorf("%s ↩\n%s", err, stack.Path())
102-
log.Errorf(context.Background(), log.TagApp, "%v", err)
102+
log.Errorf(context.Background(), log.TagAppDef, "%v", err)
103103
}
104104
}()
105105

@@ -272,7 +272,7 @@ func (c *Injector) getBean(t reflect.Type, tag WireTag, stack *Stack) (BeanRunti
272272
}
273273
if !slices.Contains(foundBeans, b) {
274274
foundBeans = append(foundBeans, b)
275-
log.Warnf(context.Background(), log.TagApp, "you should call Export() on %s", b)
275+
log.Warnf(context.Background(), log.TagAppDef, "you should call Export() on %s", b)
276276
}
277277
}
278278
}
@@ -566,7 +566,7 @@ func (c *Injector) getBeanValue(b BeanRuntime, stack *Stack) (reflect.Value, err
566566
out, err := b.Callable().Call(NewArgContext(c, stack))
567567
if err != nil {
568568
if c.forceAutowireIsNullable {
569-
log.Warnf(context.Background(), log.TagApp, "autowire error: %v", err)
569+
log.Warnf(context.Background(), log.TagAppDef, "autowire error: %v", err)
570570
return reflect.Value{}, nil
571571
}
572572
return reflect.Value{}, err
@@ -576,7 +576,7 @@ func (c *Injector) getBeanValue(b BeanRuntime, stack *Stack) (reflect.Value, err
576576
if o := out[len(out)-1]; util.IsErrorType(o.Type()) {
577577
if i := o.Interface(); i != nil {
578578
if c.forceAutowireIsNullable {
579-
log.Warnf(context.Background(), log.TagApp, "autowire error: %v", err)
579+
log.Warnf(context.Background(), log.TagAppDef, "autowire error: %v", err)
580580
return reflect.Value{}, nil
581581
}
582582
return reflect.Value{}, i.(error)
@@ -746,7 +746,7 @@ func NewStack() *Stack {
746746

747747
// pushBean records that bean b is being wired, used for cycle detection.
748748
func (s *Stack) pushBean(b *gs_bean.BeanDefinition) {
749-
log.Debugf(context.Background(), log.TagApp, "push %s %s", b, b.Status())
749+
log.Debugf(context.Background(), log.TagAppDef, "push %s %s", b, b.Status())
750750
s.beans = append(s.beans, b)
751751
}
752752

@@ -756,7 +756,7 @@ func (s *Stack) popBean() {
756756
b := s.beans[n-1]
757757
s.beans[n-1] = nil
758758
s.beans = s.beans[:n-1]
759-
log.Debugf(context.Background(), log.TagApp, "pop %s %s", b, b.Status())
759+
log.Debugf(context.Background(), log.TagAppDef, "pop %s %s", b, b.Status())
760760
}
761761

762762
// Path builds a readable representation of the wiring stack path for errors.
@@ -810,7 +810,7 @@ func (s *Stack) getSortedDestroyers() []func() {
810810
fnValue := reflect.ValueOf(fn)
811811
out := fnValue.Call([]reflect.Value{v})
812812
if len(out) > 0 && !out[0].IsNil() {
813-
log.Errorf(context.Background(), log.TagApp, "%v", out[0].Interface())
813+
log.Errorf(context.Background(), log.TagAppDef, "%v", out[0].Interface())
814814
}
815815
}
816816
}

0 commit comments

Comments
 (0)