Allow different loglevels
This commit is contained in:
parent
7134c15e86
commit
789b98015f
@ -3,7 +3,6 @@ This module contains the argument manager class
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from typing import List, NamedTuple, Optional
|
from typing import List, NamedTuple, Optional
|
||||||
@ -64,11 +63,10 @@ class Arguments(object):
|
|||||||
"""
|
"""
|
||||||
self.parser.add_argument(
|
self.parser.add_argument(
|
||||||
'-v', '--verbose',
|
'-v', '--verbose',
|
||||||
help='be verbose',
|
help='verbose mode (-vv for more, -vvv to get all messages)',
|
||||||
action='store_const',
|
action='count',
|
||||||
dest='loglevel',
|
dest='loglevel',
|
||||||
const=logging.DEBUG,
|
default=0,
|
||||||
default=logging.INFO,
|
|
||||||
)
|
)
|
||||||
self.parser.add_argument(
|
self.parser.add_argument(
|
||||||
'--version',
|
'--version',
|
||||||
|
@ -12,10 +12,22 @@ from jsonschema import Draft4Validator, validate
|
|||||||
from jsonschema.exceptions import ValidationError, best_match
|
from jsonschema.exceptions import ValidationError, best_match
|
||||||
|
|
||||||
from freqtrade import OperationalException, constants
|
from freqtrade import OperationalException, constants
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def set_loggers(log_level: int = 0) -> None:
|
||||||
|
"""
|
||||||
|
Set the logger level for Third party libs
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
logging.getLogger('requests').setLevel(logging.INFO if log_level <= 1 else logging.DEBUG)
|
||||||
|
logging.getLogger("urllib3").setLevel(logging.INFO if log_level <= 1 else logging.DEBUG)
|
||||||
|
logging.getLogger('ccxt.base.exchange').setLevel(
|
||||||
|
logging.INFO if log_level <= 2 else logging.DEBUG)
|
||||||
|
logging.getLogger('telegram').setLevel(logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
class Configuration(object):
|
class Configuration(object):
|
||||||
"""
|
"""
|
||||||
Class to read and init the bot configuration
|
Class to read and init the bot configuration
|
||||||
@ -81,9 +93,10 @@ class Configuration(object):
|
|||||||
if 'loglevel' in self.args and self.args.loglevel:
|
if 'loglevel' in self.args and self.args.loglevel:
|
||||||
config.update({'loglevel': self.args.loglevel})
|
config.update({'loglevel': self.args.loglevel})
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=config['loglevel'],
|
level=logging.DEBUG,
|
||||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||||
)
|
)
|
||||||
|
set_loggers(config['loglevel'])
|
||||||
logger.info('Log level set to %s', logging.getLevelName(config['loglevel']))
|
logger.info('Log level set to %s', logging.getLevelName(config['loglevel']))
|
||||||
|
|
||||||
# Add dynamic_whitelist if found
|
# Add dynamic_whitelist if found
|
||||||
|
@ -10,7 +10,7 @@ from typing import List
|
|||||||
|
|
||||||
from freqtrade import OperationalException
|
from freqtrade import OperationalException
|
||||||
from freqtrade.arguments import Arguments
|
from freqtrade.arguments import Arguments
|
||||||
from freqtrade.configuration import Configuration
|
from freqtrade.configuration import Configuration, set_loggers
|
||||||
from freqtrade.freqtradebot import FreqtradeBot
|
from freqtrade.freqtradebot import FreqtradeBot
|
||||||
from freqtrade.state import State
|
from freqtrade.state import State
|
||||||
from freqtrade.rpc import RPCMessageType
|
from freqtrade.rpc import RPCMessageType
|
||||||
@ -84,16 +84,6 @@ def reconfigure(freqtrade: FreqtradeBot, args: Namespace) -> FreqtradeBot:
|
|||||||
return freqtrade
|
return freqtrade
|
||||||
|
|
||||||
|
|
||||||
def set_loggers() -> None:
|
|
||||||
"""
|
|
||||||
Set the logger level for Third party libs
|
|
||||||
:return: None
|
|
||||||
"""
|
|
||||||
logging.getLogger('requests.packages.urllib3').setLevel(logging.INFO)
|
|
||||||
logging.getLogger('ccxt.base.exchange').setLevel(logging.INFO)
|
|
||||||
logging.getLogger('telegram').setLevel(logging.INFO)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
set_loggers()
|
set_loggers()
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
Loading…
Reference in New Issue
Block a user