From 9aafb7a743c59f51812f82bd55593e62b78118ab Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 20 Oct 2021 11:40:15 -0400 Subject: [PATCH] logging --- lbry/wallet/server/db/elasticsearch/sync.py | 7 +++--- lbry/wallet/server/leveldb.py | 25 +++------------------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/lbry/wallet/server/db/elasticsearch/sync.py b/lbry/wallet/server/db/elasticsearch/sync.py index 7fd76e64b..86614ecd6 100644 --- a/lbry/wallet/server/db/elasticsearch/sync.py +++ b/lbry/wallet/server/db/elasticsearch/sync.py @@ -47,8 +47,8 @@ async def get_recent_claims(blocks: int, index_name='claims', db=None): else: logging.warning("could not sync claim %s", touched.hex()) if cnt % 10000 == 0: - print(f"{cnt} claims sent") - print("sent %i claims, deleted %i" % (len(touched_claims), len(deleted_claims))) + logging.info("%i claims sent to ES", cnt) + logging.info("finished sending %i claims to ES, deleted %i", cnt, len(touched_claims), len(deleted_claims)) finally: if need_open: db.close() @@ -60,6 +60,7 @@ async def get_all_claims(index_name='claims', db=None): db = db or LevelDB(env) if need_open: await db.open_dbs() + logging.info("Fetching claims to send ES from leveldb") try: cnt = 0 async for claim in db.all_claims_producer(): @@ -72,7 +73,7 @@ async def get_all_claims(index_name='claims', db=None): } cnt += 1 if cnt % 10000 == 0: - print(f"{cnt} claims sent") + logging.info("sent %i claims to ES", cnt) finally: if need_open: db.close() diff --git a/lbry/wallet/server/leveldb.py b/lbry/wallet/server/leveldb.py index 6fe42fd13..24a742a24 100644 --- a/lbry/wallet/server/leveldb.py +++ b/lbry/wallet/server/leveldb.py @@ -498,19 +498,9 @@ class LevelDB: script.parse() return Claim.from_bytes(script.values['claim']) except: - self.logger.error( - "tx parsing for ES went boom %s %s", tx_hash[::-1].hex(), - (raw or b'').hex() - ) + self.logger.error("claim parsing for ES failed with tx: %s", tx_hash[::-1].hex()) return - def _prepare_claim_for_sync(self, claim_hash: bytes): - claim = self._fs_get_claim_by_hash(claim_hash) - if not claim: - print("wat") - return - return self._prepare_claim_metadata(claim_hash, claim) - def _prepare_claim_metadata(self, claim_hash: bytes, claim: ResolveResult): metadata = self.get_claim_metadata(claim.tx_hash, claim.position) if not metadata: @@ -552,19 +542,10 @@ class LevelDB: ).outputs[reposted_claim.position] reposted_script = OutputScript(reposted_claim_txo.pk_script) reposted_script.parse() - except: - self.logger.error( - "repost tx parsing for ES went boom %s %s", reposted_tx_hash[::-1].hex(), - raw_reposted_claim_tx.hex() - ) - return - try: reposted_metadata = Claim.from_bytes(reposted_script.values['claim']) except: - self.logger.error( - "reposted claim parsing for ES went boom %s %s", reposted_tx_hash[::-1].hex(), - raw_reposted_claim_tx.hex() - ) + self.logger.error("failed to parse reposted claim in tx %s that was reposted by %s", + reposted_tx_hash[::-1].hex(), claim_hash.hex()) return if reposted_metadata: if reposted_metadata.is_stream: