Use proper logging (using the Filter's logger)

This commit is contained in:
hroff-1902
2020-05-19 23:51:39 +03:00
parent e96e28df07
commit 696c7e87f2
3 changed files with 10 additions and 12 deletions

View File

@@ -93,7 +93,7 @@ class PairListManager():
# Validation against blacklist happens after the chain of Pairlist Handlers
# to ensure blacklist is respected.
pairlist = self.verify_blacklist(pairlist, True)
pairlist = self.verify_blacklist(pairlist, logger.warning)
self._whitelist = pairlist
@@ -110,21 +110,19 @@ class PairListManager():
return pairlist
def verify_blacklist(self, pairlist: List[str], aswarning: bool) -> List[str]:
def verify_blacklist(self, pairlist: List[str], logmethod) -> List[str]:
"""
Verify and remove items from pairlist - returning a filtered pairlist.
Logs a warning or info depending on `aswarning`.
Pairlist Handlers explicitly using this method shall use `aswarning=False`!
Pairlist Handlers explicitly using this method shall use
`logmethod=logger.info` to avoid spamming with warning messages
:param pairlist: Pairlist to validate
:param aswarning: Log message as Warning or Info
:param logmethod: Function that'll be called, `logger.info` or `logger.warning`.
:return: pairlist - blacklisted pairs
"""
for pair in deepcopy(pairlist):
if pair in self._blacklist:
if aswarning:
logger.warning(f"Pair {pair} in your blacklist. Removing it from whitelist...")
else:
logger.info(f"Pair {pair} in your blacklist. Removing it from whitelist...")
logmethod(f"Pair {pair} in your blacklist. Removing it from whitelist...")
pairlist.remove(pair)
return pairlist