Updated logger in custom_hyperopt

This commit is contained in:
Stephen Dade 2018-03-31 17:21:15 +11:00 committed by Matthias
parent 40368bd1b2
commit e0f420983e

View File

@ -4,6 +4,7 @@
This module load custom hyperopts This module load custom hyperopts
""" """
import importlib import importlib
import logging
import os import os
import sys import sys
from typing import Dict, Any, Callable from typing import Dict, Any, Callable
@ -11,11 +12,12 @@ from typing import Dict, Any, Callable
from pandas import DataFrame from pandas import DataFrame
from freqtrade.constants import Constants from freqtrade.constants import Constants
from freqtrade.logger import Logger
from freqtrade.optimize.interface import IHyperOpt from freqtrade.optimize.interface import IHyperOpt
sys.path.insert(0, r'../../user_data/hyperopts') sys.path.insert(0, r'../../user_data/hyperopts')
logger = logging.getLogger(__name__)
class CustomHyperOpt(object): class CustomHyperOpt(object):
""" """
@ -27,7 +29,6 @@ class CustomHyperOpt(object):
:param config: :param config:
:return: :return:
""" """
self.logger = Logger(name=__name__).get_logger()
# Verify the hyperopt is in the configuration, otherwise fallback to the default hyperopt # Verify the hyperopt is in the configuration, otherwise fallback to the default hyperopt
if 'hyperopt' in config: if 'hyperopt' in config:
@ -58,12 +59,12 @@ class CustomHyperOpt(object):
# Fallback to the default hyperopt # Fallback to the default hyperopt
except (ImportError, TypeError) as error: except (ImportError, TypeError) as error:
self.logger.error( logger.error(
"Impossible to load Hyperopt 'user_data/hyperopts/%s.py'. This file does not exist" "Impossible to load Hyperopt 'user_data/hyperopts/%s.py'. This file does not exist"
" or contains Python code errors", " or contains Python code errors",
hyperopt_name hyperopt_name
) )
self.logger.error( logger.error(
"The error is:\n%s.", "The error is:\n%s.",
error error
) )
@ -77,7 +78,7 @@ class CustomHyperOpt(object):
module = importlib.import_module(filename, __package__) module = importlib.import_module(filename, __package__)
custom_hyperopt = getattr(module, module.class_name) custom_hyperopt = getattr(module, module.class_name)
self.logger.info("Load hyperopt class: %s (%s.py)", module.class_name, filename) logger.info("Load hyperopt class: %s (%s.py)", module.class_name, filename)
return custom_hyperopt() return custom_hyperopt()
@staticmethod @staticmethod