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

@ -86,14 +86,14 @@ class IPairList(ABC):
:return: new whitelist
"""
def verify_blacklist(self, pairlist: List[str]) -> List[str]:
def verify_blacklist(self, pairlist: List[str], logmethod) -> List[str]:
"""
Proxy method to verify_blacklist for easy access for child classes.
Uses `aswarning=False`, as it should be for Pairlist Handlers.
:param pairlist: Pairlist to validate
:param logmethod: Function that'll be called, `logger.info` or `logger.warning`.
:return: pairlist - blacklisted pairs
"""
return self._pairlistmanager.verify_blacklist(pairlist, aswarning=False)
return self._pairlistmanager.verify_blacklist(pairlist, logmethod)
def _whitelist_for_active_markets(self, pairlist: List[str]) -> List[str]:
"""

View File

@ -115,7 +115,7 @@ class VolumePairList(IPairList):
# Validate whitelist to only have active market pairs
pairs = self._whitelist_for_active_markets([s['symbol'] for s in sorted_tickers])
pairs = self.verify_blacklist(pairs)
pairs = self.verify_blacklist(pairs, logger.info)
# Limit pairlist to the requested number of pairs
pairs = pairs[:self._number_pairs]

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