-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
executable file
·75 lines (63 loc) · 2.03 KB
/
logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Package vm
//
// @author: xwc1125
package vm
import (
"math/big"
"github.com/chain5j/chain5j-pkg/math"
"github.com/chain5j/chain5j-pkg/types"
"github.com/chain5j/chain5j-pkg/util/hexutil"
"github.com/chain5j/chain5j-protocol/protocol"
)
type Storage map[types.Hash]types.Hash
func (s Storage) Copy() Storage {
cpy := make(Storage)
for key, value := range s {
cpy[key] = value
}
return cpy
}
// LogConfig 日志配置
type LogConfig struct {
DisableMemory bool // 是否内存捕获
DisableStack bool // 是否stack捕获
DisableStorage bool // 是否storage捕获
Debug bool // 是否打印捕获日志
Limit int // 最大的日志输出,0代表不限制
}
//go:generate gencodec -type StructLog -field-override structLogMarshaling -out gen_structlog.go
// StructLog is emitted to the VM each cycle and lists information about the current internal state
// prior to the execution of the statement.
type StructLog struct {
Pc uint64 `json:"pc"`
Op protocol.OPCode `json:"op"`
Gas uint64 `json:"gas"`
GasCost uint64 `json:"gas_cost"`
Memory []byte `json:"memory"`
MemorySize int `json:"memory_size"`
Stack []*big.Int `json:"stack"`
Storage map[types.Hash]types.Hash `json:"-"`
Depth int `json:"depth"`
Err error `json:"-"`
}
type DebugLog struct {
PrintMsg string `json:"print_msg"`
}
// overrides for gencodec
type structLogMarshaling struct {
Stack []*math.HexOrDecimal256
Gas math.HexOrDecimal64
GasCost math.HexOrDecimal64
Memory hexutil.Bytes
OpName string `json:"op_name"` // adds call to OpName() in MarshalJSON
ErrorString string `json:"error"` // adds call to ErrorString() in MarshalJSON
}
func (s *StructLog) OpName() string {
return s.Op.String()
}
func (s *StructLog) ErrorString() string {
if s.Err != nil {
return s.Err.Error()
}
return ""
}