import logging


def setup_logger(fname=None, silent=False):
    if fname is None:
        logging.basicConfig(
            level=logging.INFO if not silent else logging.CRITICAL,
            format='%(name)-12s: %(levelname)-8s %(message)s',
            datefmt='%m-%d %H:%M',
            filemode='w'
        )
    else:
        logging.basicConfig(
            level=logging.INFO if not silent else logging.CRITICAL,
            format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
            datefmt='%m-%d %H:%M',
            filename=fname,
            filemode='w'
        )
        console = logging.StreamHandler()
        console.setLevel(logging.INFO)
        formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

[((6, 8, 11, 9), 'logging.basicConfig', 'logging.basicConfig', (), '', False, 'import logging\n'), ((13, 8, 19, 9), 'logging.basicConfig', 'logging.basicConfig', (), '', False, 'import logging\n'), ((20, 18, 20, 41), 'logging.StreamHandler', 'logging.StreamHandler', ({}, {}), '()', False, 'import logging\n'), ((22, 20, 22, 81), 'logging.Formatter', 'logging.Formatter', ({(22, 38, 22, 80): '"""%(name)-12s: %(levelname)-8s %(message)s"""'}, {}), "('%(name)-12s: %(levelname)-8s %(message)s')", False, 'import logging\n'), ((24, 8, 24, 29), 'logging.getLogger', 'logging.getLogger', ({(24, 26, 24, 28): '""""""'}, {}), "('')", False, 'import logging\n')]