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, 'logging.basicConfig', 'logging.basicConfig', False, 'import logging\n'), (13, 'logging.basicConfig', 'logging.basicConfig', False, 'import logging\n'), (20, 'logging.StreamHandler', 'logging.StreamHandler', False, 'import logging\n'), (22, 'logging.Formatter', 'logging.Formatter', False, 'import logging\n'), (24, 'logging.getLogger', 'logging.getLogger', False, 'import logging\n')]