import logging
import logging.config

from log_conf import conf


class Log(object):
    def __init__(self):
        # 配置
        logging.config.dictConfig(conf)

    def __console(self, level, message):
        if level == 'info':
            logger = logging.getLogger('sls')
            logger.info(message)
        elif level == 'debug':
            logger = logging.getLogger('root')
            logger.debug(message)
        elif level == 'warning':
            logger = logging.getLogger('root')
            logger.warning(message)
        elif level == 'error':
            logger = logging.getLogger('error')
            logger.error(message)

    def debug(self, message):
        self.__console('debug', message)
        # return

    def info(self, message):
        self.__console('info', message)
        # return

    def warning(self, message):
        self.__console('warning', message)
        # return

    def error(self, message):
        self.__console('error', message)
        # return
