def set_logger(args):
    'Write logs to console and log file.\n    '
    log_file = os.path.join(args.save_path, 'train.log')
    logging.basicConfig(format='%(asctime)s %(levelname)-8s %(message)s', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S', filename=log_file, filemode='a+')
    if args.print_on_screen:
        console = logging.StreamHandler()
        console.setLevel(logging.INFO)
        formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)
    for arg in vars(args):
        logging.info('{:20}:{}'.format(arg, getattr(args, arg)))
Write logs to console and log file.
def set_logger(args):
    '\n    '
    log_file = os.path.join(args.save_path, 'train.log')
    logging.basicConfig(format='%(asctime)s %(levelname)-8s %(message)s', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S', filename=log_file, filemode='a+')
    if args.print_on_screen:
        console = logging.StreamHandler()
        console.setLevel(logging.INFO)
        formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger().addHandler(console)
    for arg in vars(args):
        logging.info('{:20}:{}'.format(arg, getattr(args, arg)))