1
0
Fork 0
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:
Sergey Cherepanov 2023-05-18 13:35:49 +02:00 committed by Mikhail Iudin
parent b1ad0be3b4
commit 8c84ab9b31
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
2 changed files with 7 additions and 1 deletions

View file

@ -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))...)
}

View file

@ -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
}