def build_log_file(cfg):
FORMAT="%(asctime)s;%(levelname)s|%(message)s"
DATEF="%H-%M-%S"
logging.basicConfig(formatter=FORMAT, level=logging.DEBUG)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(filename=os.path.join(cfg['outfolder'], 'logfile'+time.strftime("%m-%d")+'.log'))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s;%(levelname)s|%(message)s", "%H:%M:%S")
fh.setFormatter(formatter)
logger.addHandler(fh)
LEVEL_STYLES = dict(
debug=dict(color='magenta'),
info=dict(color='green'),
verbose=dict(),
warning=dict(color='blue'),
error=dict(color='yellow'),
critical=dict(color='red',bold=True))
coloredlogs.install(level=logging.DEBUG, fmt=FORMAT, datefmt=DATEF, level_styles=LEVEL_STYLES)
args_dict = cfg
sorted_args = sorted(args_dict.items(), key=operator.itemgetter(0))
logging.info('######################################################')
logging.info('# --Configurable Parameters In this Model--')
for name, val in sorted_args:
logging.info("# " + name + ":\t" + str(get_list_name(val)))
logging.info('######################################################')
评论列表
文章目录