mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
write app version to rpc log
This commit is contained in:
parent
b1ad0be3b4
commit
8c84ab9b31
2 changed files with 7 additions and 1 deletions
|
@ -35,6 +35,10 @@ func Identity(val string) zap.Field {
|
|||
return zap.String("identity", val)
|
||||
}
|
||||
|
||||
func App(app string) zap.Field {
|
||||
return zap.String("app", app)
|
||||
}
|
||||
|
||||
func FileId(fileId string) zap.Field {
|
||||
return zap.String("fileId", fileId)
|
||||
}
|
||||
|
@ -57,5 +61,5 @@ func (m *metric) RequestLog(ctx context.Context, rpc string, fields ...zap.Field
|
|||
if ak != nil {
|
||||
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
|
||||
config Config
|
||||
a *app.App
|
||||
appField zap.Field
|
||||
}
|
||||
|
||||
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.config = a.MustComponent("config").(configSource).GetMetric()
|
||||
m.rpcLog = logger.NewNamed("rpcLog")
|
||||
m.appField = App(a.Version())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue