Skip to content

Commit

Permalink
chore: build logger strings lazily (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Nov 2, 2024
1 parent 55e35f1 commit 5ce8d88
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions eth_portfolio/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ def set_end_block_if_none(func: Callable[Concatenate[_I, Block, Block, _P], _T])
async def wrap(obj: _I, start_block: Block, end_block: Optional[Block], *args: _P.args, **kwargs: _P.kwargs) -> _T:
if end_block is None:
end_block = await get_buffered_chain_height()
logger.debug(f"end_block not provided, using {end_block}")
logger.debug("end_block not provided, using %s", end_block)
async for thing in func(obj, start_block, end_block, *args, **kwargs):
yield thing
elif asyncio.iscoroutinefunction(func):
@functools.wraps(func)
async def wrap(obj: _I, start_block: Block, end_block: Block, *args: _P.args, **kwargs: _P.kwargs) -> _T:
if end_block is None:
end_block = await get_buffered_chain_height()
logger.debug(f"end_block not provided, using {end_block}")
logger.debug("end_block not provided, using %s", end_block)
return await func(obj, start_block, end_block, *args, **kwargs)
else:
@functools.wraps(func)
def wrap(obj: _I, start_block: Block, end_block: Block, *args: _P.args, **kwargs: _P.kwargs) -> _T:
if end_block is None:
end_block = chain.height - _config.REORG_BUFFER
logger.debug(f"end_block not provided, using {end_block}")
logger.debug("end_block not provided, using %s", end_block)
return func(obj, start_block, end_block, *args, **kwargs)
return wrap
2 changes: 1 addition & 1 deletion eth_portfolio/buckets.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def _unwrap_token(token) -> str:
return token

def _pool_bucket(pool_tokens: set) -> Optional[str]:
logger.debug(f'Pool tokens: {pool_tokens}')
logger.debug('Pool tokens: %s', pool_tokens)
if pool_tokens < BTC_LIKE:
return list(BTC_LIKE)[0]
if pool_tokens < ETH_LIKE:
Expand Down
2 changes: 1 addition & 1 deletion eth_portfolio/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ async def imported_func(self: Portfolio, *args: Any, **kwargs: Any) -> _argspec.
"""
return await a_sync.gather({address: func(address, *args, **kwargs, sync=False) for address in self})
setattr(Portfolio, func_name, imported_func)
logger.debug(f"Ported {func_name} from PortfolioAddress to Portfolio")
logger.debug("Ported %s from PortfolioAddress to Portfolio", func_name)


def _get_missing_cols_from_KeyError(e: KeyError) -> List[str]:
Expand Down

0 comments on commit 5ce8d88

Please sign in to comment.