freqtrade_origin/freqtrade/logger.py
Gerald Lonlas 3b9e828fa4 Add a class Logger to manage the logging messages
This class will evolve later to support color logging. For now
it is used to not repeat the logging configuration everywhere.
2018-03-03 09:33:54 +08:00

41 lines
1011 B
Python

# pragma pylint: disable=too-few-public-methods
"""
This module contains the class for logger and logging messages
"""
import logging
class Logger(object):
"""
Logging class
"""
def __init__(self, name='', level=logging.INFO) -> None:
"""
Init the logger class
:param name: Name of the Logger scope
:param level: Logger level that should be used
:return: None
"""
self.name = name
self.level = level
self._init_logger()
def _init_logger(self) -> logging:
"""
Setup the bot logger configuration
:return: logging object
"""
logging.basicConfig(
level=self.level,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
)
def get_logger(self) -> logging.RootLogger:
"""
Return the logger instance to use for sending message
:return: the logger instance
"""
return logging.getLogger(self.name)