AzurLaneAutoScript/deploy/logger.py
2023-09-19 23:14:37 +08:00

42 lines
979 B
Python

import logging
import os
import sys
os.chdir(os.path.join(os.path.dirname(__file__), '../'))
logger = logging.getLogger("deploy")
_logger = logger
formatter = logging.Formatter(fmt="%(message)s")
hdlr = logging.StreamHandler(stream=sys.stdout)
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.INFO)
def hr(title, level=3):
if logger is not _logger:
return logger.hr(title, level)
title = str(title).upper()
if level == 0:
middle = "|" + " " * 20 + title + " " * 20 + "|"
border = "+" + "-" * (len(middle) - 2) + "+"
logger.info(border)
logger.info(middle)
logger.info(border)
if level == 1:
logger.info("=" * 20 + " " + title + " " + "=" * 20)
if level == 2:
logger.info("-" * 20 + " " + title + " " + "-" * 20)
if level == 3:
logger.info(f"<<< {title} >>>")
def attr(name, text):
print(f'[{name}] {text}')
logger.hr = hr
logger.attr = attr