write app version to rpc log
This commit is contained in:
parent
b1ad0be3b4
commit
8c84ab9b31
@ -35,6 +35,10 @@ func Identity(val string) zap.Field {
|
|||||||
return zap.String("identity", val)
|
return zap.String("identity", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func App(app string) zap.Field {
|
||||||
|
return zap.String("app", app)
|
||||||
|
}
|
||||||
|
|
||||||
func FileId(fileId string) zap.Field {
|
func FileId(fileId string) zap.Field {
|
||||||
return zap.String("fileId", fileId)
|
return zap.String("fileId", fileId)
|
||||||
}
|
}
|
||||||
@ -57,5 +61,5 @@ func (m *metric) RequestLog(ctx context.Context, rpc string, fields ...zap.Field
|
|||||||
if ak != nil {
|
if ak != nil {
|
||||||
acc = ak.Account()
|
acc = ak.Account()
|
||||||
}
|
}
|
||||||
m.rpcLog.Info("", append(fields, PeerId(peerId), Identity(acc), Method(rpc))...)
|
m.rpcLog.Info("", append(fields, m.appField, PeerId(peerId), Identity(acc), Method(rpc))...)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@ type metric struct {
|
|||||||
rpcLog logger.CtxLogger
|
rpcLog logger.CtxLogger
|
||||||
config Config
|
config Config
|
||||||
a *app.App
|
a *app.App
|
||||||
|
appField zap.Field
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *metric) Init(a *app.App) (err error) {
|
func (m *metric) Init(a *app.App) (err error) {
|
||||||
@ -40,6 +41,7 @@ func (m *metric) Init(a *app.App) (err error) {
|
|||||||
m.registry = prometheus.NewRegistry()
|
m.registry = prometheus.NewRegistry()
|
||||||
m.config = a.MustComponent("config").(configSource).GetMetric()
|
m.config = a.MustComponent("config").(configSource).GetMetric()
|
||||||
m.rpcLog = logger.NewNamed("rpcLog")
|
m.rpcLog = logger.NewNamed("rpcLog")
|
||||||
|
m.appField = App(a.Version())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user