Files
chia-blockchain/chia/util/log_exceptions.py
T
Chris MarslenderandGitHub 677e25fd02 Add data to wallet RPCs to support metrics (+ update log_exceptions helper) (#9996)
* Send coin_added event to metrics

* Add fingerprint to balance response

* Don't consume the exception by default, but enable for the metrics data usecases

* Pass sync_changed event to metrics

* bare raise
2022-01-31 18:53:43 -08:00

14 lines
328 B
Python

from contextlib import contextmanager
import logging
import traceback
@contextmanager
def log_exceptions(log: logging.Logger, *, consume: bool = False):
try:
yield
except Exception as e:
log.error(f"Caught Exception: {e}. Traceback: {traceback.format_exc()}")
if not consume:
raise