Exemple #1
0
    def on_config_update(self, raw_config: dict):
        log_level = self.log_level_map[self.log_level]
        consoleHandler.setLevel(log_level)

        try:
            from lanzou.api.utils import logger as lanzou_logger

            # 将lanzou的日志也显示
            lanzou_logger.setLevel(log_level)
        except Exception:
            pass
        if type(self.log_colors) is dict:
            for level, log_color in self.log_colors.items():
                consoleLogFormatter.log_colors[level] = log_color

        # 由于经常会有人填写成数字的列表,如[123, 456],导致后面从各个dict中取值时出错(dict中都默认QQ为str类型,若传入int类型,会取不到对应的值)
        # 所以这里做下兼容,强制转换为str
        self.auto_send_card_target_qqs = [str(qq) for qq in self.auto_send_card_target_qqs]
        self.sailiyam_visit_target_qqs = [str(qq) for qq in self.sailiyam_visit_target_qqs]

        url_config_filepath = "utils/url.toml"
        if os.path.isfile(url_config_filepath):
            try:
                with open(url_config_filepath, 'r', encoding='utf-8-sig') as url_config_file:
                    url_config = toml.load(url_config_file)
                    if 'pay_by_month_purchase_url' in url_config:
                        self.pay_by_month_purchase_url = url_config['pay_by_month_purchase_url']
                    if 'netdisk_link' in url_config:
                        self.netdisk_link = url_config['netdisk_link']
            except:
                pass
Exemple #2
0
    def on_config_update(self, raw_config: dict):
        log_level = self.log_level_map[self.log_level]
        consoleHandler.setLevel(log_level)

        try:
            from lanzou.api.utils import logger as lanzou_logger

            # 将lanzou的日志也显示
            lanzou_logger.setLevel(log_level)
        except Exception:
            pass
        if type(self.log_colors) is dict:
            for level, log_color in self.log_colors.items():
                consoleLogFormatter.log_colors[level] = log_color

        # 由于经常会有人填写成数字的列表,如[123, 456],导致后面从各个dict中取值时出错(dict中都默认QQ为str类型,若传入int类型,会取不到对应的值)
        # 所以这里做下兼容,强制转换为str
        self.auto_send_card_target_qqs = [str(qq) for qq in self.auto_send_card_target_qqs]
        self.sailiyam_visit_target_qqs = [str(qq) for qq in self.sailiyam_visit_target_qqs]
Exemple #3
0
            "CRITICAL": "fg_bold_red",
        },
    },
    secondary_log_colors={},
    style="%",
)
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(consoleLogFormatter)
consoleHandler.setLevel(logging.INFO)
logger.addHandler(consoleHandler)

try:
    from lanzou.api.utils import logger as lanzou_logger

    # 将lanzou的日志也显示
    lanzou_logger.setLevel(logging.INFO)
except Exception:
    pass


def color(color_name):
    return consoleLogFormatter._get_escape_code(consoleLogFormatter.log_colors,
                                                color_name)


def with_color(color_name: str, value) -> str:
    return color(color_name) + str(value) + asciiReset


def get_log_func(log_func: Callable, show_log=True) -> Callable:
    if not show_log: