Skip to content

Commit ba08e5d

Browse files
robertpipermerriam
authored andcommitted
Rename TRACE log level to DEBUG2
1 parent 7d085bd commit ba08e5d

File tree

35 files changed

+152
-150
lines changed

35 files changed

+152
-150
lines changed

eth/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import sys
33

44
from eth.tools.logging import (
5-
setup_trace_logging
5+
setup_extended_logging
66
)
77

88
#
99
# Setup TRACE level logging.
1010
#
1111
# This needs to be done before the other imports
12-
setup_trace_logging()
12+
setup_extended_logging()
1313

1414
from eth.chains import ( # noqa: F401
1515
Chain,

eth/db/account.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
validate_canonical_address,
5050
)
5151
from eth.tools.logging import (
52-
TraceLogger
52+
ExtendedDebugLogger
5353
)
5454
from eth.utils.padding import (
5555
pad32,
@@ -178,7 +178,7 @@ def persist(self) -> None:
178178

179179
class AccountDB(BaseAccountDB):
180180

181-
logger = cast(TraceLogger, logging.getLogger('eth.db.account.AccountDB'))
181+
logger = cast(ExtendedDebugLogger, logging.getLogger('eth.db.account.AccountDB'))
182182

183183
def __init__(self, db: BaseDB, state_root: Hash32=BLANK_ROOT_HASH) -> None:
184184
r"""
@@ -407,7 +407,7 @@ def commit(self, changeset: Tuple[UUID, UUID]) -> None:
407407
self._journaltrie.commit(trie_changeset)
408408

409409
def make_state_root(self) -> Hash32:
410-
self.logger.trace("Generating AccountDB trie")
410+
self.logger.debug2("Generating AccountDB trie")
411411
self._journaldb.persist()
412412
self._journaltrie.persist()
413413
return self.state_root
@@ -428,7 +428,7 @@ def _log_pending_accounts(self) -> None:
428428
else:
429429
accounts_displayed.add(address)
430430
account = self._get_account(Address(address))
431-
self.logger.trace(
431+
self.logger.debug2(
432432
"Account %s: balance %d, nonce %d, storage root %s, code hash %s",
433433
encode_hex(address),
434434
account.balance,

eth/tools/logging.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import logging
22
from typing import Any
33

4-
TRACE_LEVEL_NUM = 5
4+
DEBUG2_LEVEL_NUM = 8
55

66

7-
class TraceLogger(logging.Logger):
7+
class ExtendedDebugLogger(logging.Logger):
88

9-
def trace(self, message: str, *args: Any, **kwargs: Any) -> None:
10-
self.log(TRACE_LEVEL_NUM, message, *args, **kwargs)
9+
def debug2(self, message: str, *args: Any, **kwargs: Any) -> None:
10+
self.log(DEBUG2_LEVEL_NUM, message, *args, **kwargs)
1111

1212

13-
def setup_trace_logging() -> None:
14-
logging.setLoggerClass(TraceLogger)
15-
logging.addLevelName(TRACE_LEVEL_NUM, 'TRACE')
16-
setattr(logging, 'TRACE', TRACE_LEVEL_NUM) # typing: ignore
13+
def setup_extended_logging() -> None:
14+
logging.setLoggerClass(ExtendedDebugLogger)
15+
logging.addLevelName(DEBUG2_LEVEL_NUM, 'DEBUG2')
16+
setattr(logging, 'DEBUG2', DEBUG2_LEVEL_NUM) # typing: ignore

eth/vm/computation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
VMError,
3131
)
3232
from eth.tools.logging import (
33-
TraceLogger,
33+
ExtendedDebugLogger,
3434
)
3535
from eth.utils.datatypes import (
3636
Configurable,
@@ -117,7 +117,7 @@ class BaseComputation(Configurable, ABC):
117117
opcodes = None # type: Dict[int, Any]
118118
_precompiles = None # type: Dict[Address, Callable[['BaseComputation'], 'BaseComputation']]
119119

120-
logger = cast(TraceLogger, logging.getLogger('eth.vm.computation.Computation'))
120+
logger = cast(ExtendedDebugLogger, logging.getLogger('eth.vm.computation.Computation'))
121121

122122
def __init__(self,
123123
state: BaseState,
@@ -214,7 +214,7 @@ def extend_memory(self, start_position: int, size: int) -> None:
214214
before_cost = memory_gas_cost(before_size)
215215
after_cost = memory_gas_cost(after_size)
216216

217-
self.logger.trace(
217+
self.logger.debug2(
218218
"MEMORY: size (%s -> %s) | cost (%s -> %s)",
219219
before_size,
220220
after_size,
@@ -472,7 +472,7 @@ def get_log_entries(self) -> Tuple[Tuple[bytes, List[int], bytes], ...]:
472472
# Context Manager API
473473
#
474474
def __enter__(self) -> 'BaseComputation':
475-
self.logger.trace(
475+
self.logger.debug2(
476476
(
477477
"COMPUTATION STARTING: gas: %s | from: %s | to: %s | value: %s "
478478
"| depth %s | static: %s"
@@ -489,7 +489,7 @@ def __enter__(self) -> 'BaseComputation':
489489

490490
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None:
491491
if exc_value and isinstance(exc_value, VMError):
492-
self.logger.trace(
492+
self.logger.debug2(
493493
(
494494
"COMPUTATION ERROR: gas: %s | from: %s | to: %s | value: %s | "
495495
"depth: %s | static: %s | error: %s"
@@ -515,7 +515,7 @@ def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None:
515515
# suppress VM exceptions
516516
return True
517517
elif exc_type is None:
518-
self.logger.trace(
518+
self.logger.debug2(
519519
(
520520
"COMPUTATION SUCCESS: from: %s | to: %s | value: %s | "
521521
"depth: %s | static: %s | gas-used: %s | gas-remaining: %s"
@@ -563,7 +563,7 @@ def apply_computation(cls,
563563
for opcode in computation.code:
564564
opcode_fn = computation.get_opcode_fn(opcode)
565565

566-
computation.logger.trace(
566+
computation.logger.debug2(
567567
"OPCODE: 0x%x (%s) | pc: %s",
568568
opcode,
569569
opcode_fn.mnemonic,

eth/vm/forks/frontier/computation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def apply_message(self) -> BaseComputation:
6161
self.state.account_db.delta_balance(self.msg.sender, -1 * self.msg.value)
6262
self.state.account_db.delta_balance(self.msg.storage_address, self.msg.value)
6363

64-
self.logger.trace(
64+
self.logger.debug2(
6565
"TRANSFERRED: %s from %s -> %s",
6666
self.msg.value,
6767
encode_hex(self.msg.sender),
@@ -101,7 +101,7 @@ def apply_create_message(self) -> BaseComputation:
101101
except OutOfGas:
102102
computation.output = b''
103103
else:
104-
self.logger.trace(
104+
self.logger.debug2(
105105
"SETTING CODE: %s -> length: %s | hash: %s",
106106
encode_hex(self.msg.storage_address),
107107
len(contract_code),

eth/vm/forks/frontier/state.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def build_evm_message(self, transaction: BaseOrSpoofTransaction) -> Message:
7777
data = transaction.data
7878
code = self.vm_state.account_db.get_code(transaction.to)
7979

80-
self.vm_state.logger.trace(
80+
self.vm_state.logger.debug2(
8181
(
8282
"TRANSACTION: sender: %s | to: %s | value: %s | gas: %s | "
8383
"gas-price: %s | s: %s | r: %s | v: %s | data-hash: %s"
@@ -123,7 +123,7 @@ def build_computation(self,
123123
encode_hex(message.storage_address),
124124
)
125125
)
126-
self.vm_state.logger.trace(
126+
self.vm_state.logger.debug2(
127127
"Address collision while creating contract: %s",
128128
encode_hex(message.storage_address),
129129
)
@@ -155,7 +155,7 @@ def finalize_computation(self,
155155
gas_refund_amount = (gas_refund + gas_remaining) * transaction.gas_price
156156

157157
if gas_refund_amount:
158-
self.vm_state.logger.trace(
158+
self.vm_state.logger.debug2(
159159
'TRANSACTION REFUND: %s -> %s',
160160
gas_refund_amount,
161161
encode_hex(computation.msg.sender),
@@ -166,7 +166,7 @@ def finalize_computation(self,
166166
# Miner Fees
167167
transaction_fee = \
168168
(transaction.gas - gas_remaining - gas_refund) * transaction.gas_price
169-
self.vm_state.logger.trace(
169+
self.vm_state.logger.debug2(
170170
'TRANSACTION FEE: %s -> %s',
171171
transaction_fee,
172172
encode_hex(self.vm_state.coinbase),
@@ -177,7 +177,7 @@ def finalize_computation(self,
177177
for account, beneficiary in computation.get_accounts_for_deletion():
178178
# TODO: need to figure out how we prevent multiple selfdestructs from
179179
# the same account and if this is the right place to put this.
180-
self.vm_state.logger.trace('DELETING ACCOUNT: %s', encode_hex(account))
180+
self.vm_state.logger.debug2('DELETING ACCOUNT: %s', encode_hex(account))
181181

182182
# TODO: this balance setting is likely superflous and can be
183183
# removed since `delete_account` does this.

eth/vm/forks/homestead/computation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def apply_create_message(self) -> BaseComputation:
4848
self.state.revert(snapshot)
4949
else:
5050
if self.logger:
51-
self.logger.trace(
51+
self.logger.debug2(
5252
"SETTING CODE: %s -> length: %s | hash: %s",
5353
encode_hex(self.msg.storage_address),
5454
len(contract_code),

eth/vm/forks/spurious_dragon/computation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def apply_create_message(self) -> BaseComputation:
6161
self.state.revert(snapshot)
6262
else:
6363
if self.logger:
64-
self.logger.trace(
64+
self.logger.debug2(
6565
"SETTING CODE: %s -> length: %s | hash: %s",
6666
encode_hex(self.msg.storage_address),
6767
len(contract_code),

eth/vm/forks/spurious_dragon/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def finalize_computation(self,
3434
self.vm_state.account_db.account_is_empty(account)
3535
)
3636
if should_delete:
37-
self.vm_state.logger.trace(
37+
self.vm_state.logger.debug2(
3838
"CLEARING EMPTY ACCOUNT: %s",
3939
encode_hex(account),
4040
)

eth/vm/gas_meter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
validate_uint256,
1414
)
1515
from eth.tools.logging import (
16-
TraceLogger
16+
ExtendedDebugLogger
1717
)
1818

1919

@@ -38,7 +38,7 @@ class GasMeter(object):
3838
gas_refunded = None # type: int
3939
gas_remaining = None # type: int
4040

41-
logger = cast(TraceLogger, logging.getLogger('eth.gas.GasMeter'))
41+
logger = cast(ExtendedDebugLogger, logging.getLogger('eth.gas.GasMeter'))
4242

4343
def __init__(self,
4444
start_gas: int,
@@ -67,7 +67,7 @@ def consume_gas(self, amount: int, reason: str) -> None:
6767

6868
self.gas_remaining -= amount
6969

70-
self.logger.trace(
70+
self.logger.debug2(
7171
'GAS CONSUMPTION: %s - %s -> %s (%s)',
7272
self.gas_remaining + amount,
7373
amount,
@@ -81,7 +81,7 @@ def return_gas(self, amount: int) -> None:
8181

8282
self.gas_remaining += amount
8383

84-
self.logger.trace(
84+
self.logger.debug2(
8585
'GAS RETURNED: %s + %s -> %s',
8686
self.gas_remaining - amount,
8787
amount,
@@ -91,7 +91,7 @@ def return_gas(self, amount: int) -> None:
9191
def refund_gas(self, amount: int) -> None:
9292
self.gas_refunded = self.refund_strategy(self.gas_refunded, amount)
9393

94-
self.logger.trace(
94+
self.logger.debug2(
9595
'GAS REFUND: %s + %s -> %s',
9696
self.gas_refunded - amount,
9797
amount,

0 commit comments

Comments
 (0)