package logger
import "github.com/ethereum/go-ethereum/eth/tracers/logger"
Index ¶
- func NewJSONLogger(cfg *Config, writer io.Writer) *tracing.Hooks
- func NewJSONLoggerWithCallFrames(cfg *Config, writer io.Writer) *tracing.Hooks
- func NewMarkdownLogger(cfg *Config, writer io.Writer) *mdLogger
- func WriteTrace(writer io.Writer, logs []StructLog)
- type AccessListTracer
- func NewAccessListTracer(acl types.AccessList, addressesToExclude map[common.Address]struct{}) *AccessListTracer
- func (a *AccessListTracer) AccessList() types.AccessList
- func (a *AccessListTracer) Equal(other *AccessListTracer) bool
- func (a *AccessListTracer) Hooks() *tracing.Hooks
- func (a *AccessListTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error)
- type Config
- type ExecutionResult
- type Storage
- type StructLog
- func (s *StructLog) ErrorString() string
- func (s StructLog) MarshalJSON() ([]byte, error)
- func (s *StructLog) OpName() string
- func (s *StructLog) UnmarshalJSON(input []byte) error
- func (s *StructLog) WriteTo(writer io.Writer)
- type StructLogger
- func NewStreamingStructLogger(cfg *Config, writer io.Writer) *StructLogger
- func NewStructLogger(cfg *Config) *StructLogger
- func (l *StructLogger) Error() error
- func (l *StructLogger) GetResult() (json.RawMessage, error)
- func (l *StructLogger) Hooks() *tracing.Hooks
- func (l *StructLogger) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool)
- func (l *StructLogger) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error)
- func (l *StructLogger) OnSystemCallEnd()
- func (l *StructLogger) OnSystemCallStart(env *tracing.VMContext)
- func (l *StructLogger) OnTxEnd(receipt *types.Receipt, err error)
- func (l *StructLogger) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address)
- func (l *StructLogger) Output() []byte
- func (l *StructLogger) Stop(err error)
Functions ¶
func NewJSONLogger ¶
NewJSONLogger creates a new EVM tracer that prints execution steps as JSON objects into the provided stream.
func NewJSONLoggerWithCallFrames ¶
NewJSONLoggerWithCallFrames creates a new EVM tracer that prints execution steps as JSON objects into the provided stream. It also includes call frames in the output.
func NewMarkdownLogger ¶
NewMarkdownLogger creates a logger which outputs information in a format adapted for human readability, and is also a valid markdown table
func WriteTrace ¶
WriteTrace writes a formatted trace to the given writer @deprecated
Types ¶
type AccessListTracer ¶
type AccessListTracer struct {
// contains filtered or unexported fields
}
AccessListTracer is a tracer that accumulates touched accounts and storage slots into an internal set.
func NewAccessListTracer ¶
func NewAccessListTracer(acl types.AccessList, addressesToExclude map[common.Address]struct{}) *AccessListTracer
NewAccessListTracer creates a new tracer that can generate AccessLists. An optional AccessList can be specified to occupy slots and addresses in the resulting accesslist.
func (*AccessListTracer) AccessList ¶
func (a *AccessListTracer) AccessList() types.AccessList
AccessList returns the current accesslist maintained by the tracer.
func (*AccessListTracer) Equal ¶
func (a *AccessListTracer) Equal(other *AccessListTracer) bool
Equal returns if the content of two access list traces are equal.
func (*AccessListTracer) Hooks ¶
func (a *AccessListTracer) Hooks() *tracing.Hooks
func (*AccessListTracer) OnOpcode ¶
func (a *AccessListTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error)
OnOpcode captures all opcodes that touch storage or addresses and adds them to the accesslist.
type Config ¶
type Config struct { EnableMemory bool // enable memory capture DisableStack bool // disable stack capture DisableStorage bool // disable storage capture EnableReturnData bool // enable return data capture Limit int // maximum size of output, but zero means unlimited // Chain overrides, can be used to execute a trace using future fork rules Overrides *params.ChainConfig `json:"overrides,omitempty"` }
Config are the configuration options for structured logger the EVM
type ExecutionResult ¶
type ExecutionResult struct { Gas uint64 `json:"gas"` Failed bool `json:"failed"` ReturnValue hexutil.Bytes `json:"returnValue"` StructLogs []json.RawMessage `json:"structLogs"` }
ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as transaction execution status, the amount of gas used and the return value
type Storage ¶
Storage represents a contract's storage.
type StructLog ¶
type StructLog struct { Pc uint64 `json:"pc"` Op vm.OpCode `json:"op"` Gas uint64 `json:"gas"` GasCost uint64 `json:"gasCost"` Memory []byte `json:"memory,omitempty"` MemorySize int `json:"memSize"` Stack []uint256.Int `json:"stack"` ReturnData []byte `json:"returnData,omitempty"` Storage map[common.Hash]common.Hash `json:"-"` Depth int `json:"depth"` RefundCounter uint64 `json:"refund"` Err error `json:"-"` }
StructLog is emitted to the EVM each cycle and lists information about the current internal state prior to the execution of the statement.
func (*StructLog) ErrorString ¶
ErrorString formats the log's error as a string.
func (StructLog) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*StructLog) OpName ¶
OpName formats the operand name in a human-readable format.
func (*StructLog) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
func (*StructLog) WriteTo ¶
WriteTo writes the human-readable log data into the supplied writer.
type StructLogger ¶
type StructLogger struct {
// contains filtered or unexported fields
}
StructLogger is an EVM state logger and implements EVMLogger.
StructLogger can capture state based on the given Log configuration and also keeps a track record of modified storage which is used in reporting snapshots of the contract their storage.
A StructLogger can either yield it's output immediately (streaming) or store for later output.
func NewStreamingStructLogger ¶
func NewStreamingStructLogger(cfg *Config, writer io.Writer) *StructLogger
NewStreamingStructLogger returns a new streaming logger.
func NewStructLogger ¶
func NewStructLogger(cfg *Config) *StructLogger
NewStructLogger construct a new (non-streaming) struct logger.
func (*StructLogger) Error ¶
func (l *StructLogger) Error() error
Error returns the VM error captured by the trace.
func (*StructLogger) GetResult ¶
func (l *StructLogger) GetResult() (json.RawMessage, error)
func (*StructLogger) Hooks ¶
func (l *StructLogger) Hooks() *tracing.Hooks
func (*StructLogger) OnExit ¶
OnExit is called a call frame finishes processing.
func (*StructLogger) OnOpcode ¶
func (l *StructLogger) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error)
OnOpcode logs a new structured log message and pushes it out to the environment
OnOpcode also tracks SLOAD/SSTORE ops to track storage change.
func (*StructLogger) OnSystemCallEnd ¶
func (l *StructLogger) OnSystemCallEnd()
func (*StructLogger) OnSystemCallStart ¶
func (l *StructLogger) OnSystemCallStart(env *tracing.VMContext)
func (*StructLogger) OnTxEnd ¶
func (l *StructLogger) OnTxEnd(receipt *types.Receipt, err error)
func (*StructLogger) OnTxStart ¶
func (l *StructLogger) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address)
func (*StructLogger) Output ¶
func (l *StructLogger) Output() []byte
Output returns the VM return value captured by the trace.
func (*StructLogger) Stop ¶
func (l *StructLogger) Stop(err error)
Stop terminates execution of the tracer at the first opportune moment.
Source Files ¶
access_list_tracer.go gen_callframe.go gen_structlog.go logger.go logger_json.go
- Version
- v1.16.1 (latest)
- Published
- Jul 2, 2025
- Platform
- linux/amd64
- Imports
- 17 packages
- Last checked
- 1 day ago –
Tools for package owners.