runtime: tune runtime.Log messages

Add transaction hash, print contract hash in LE (as all user-facing functions
do) and don't double-quote the message, zap already does quoting of its own.
This commit is contained in:
Roman Khimov 2021-04-07 15:32:46 +03:00
parent d33dcd557a
commit 453012ff16
2 changed files with 9 additions and 7 deletions

View file

@ -82,10 +82,14 @@ func Log(ic *interop.Context) error {
if len(state) > MaxNotificationSize {
return fmt.Errorf("message length shouldn't exceed %v", MaxNotificationSize)
}
msg := fmt.Sprintf("%q", state)
var txHash string
if ic.Tx != nil {
txHash = ic.Tx.Hash().StringLE()
}
ic.Log.Info("runtime log",
zap.Stringer("script", ic.VM.GetCurrentScriptHash()),
zap.String("logs", msg))
zap.String("tx", txHash),
zap.String("script", ic.VM.GetCurrentScriptHash().StringLE()),
zap.String("msg", state))
return nil
}