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)

[((91, 263), 'logging.basicConfig', '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"""'}), "(level=logging.INFO if not silent else logging.CRITICAL,\n    format='%(name)-12s: %(levelname)-8s %(message)s', datefmt=\n    '%m-%d %H:%M', filemode='w')\n", (110, 263), False, 'import logging\n'), ((331, 530), 'logging.basicConfig', '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"""'}), "(level=logging.INFO if not silent else logging.CRITICAL,\n    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt=\n    '%m-%d %H:%M', filename=fname, filemode='w')\n", (350, 530), False, 'import logging\n'), ((610, 633), 'logging.StreamHandler', 'logging.StreamHandler', ([], {}), '()\n', (631, 633), False, 'import logging\n'), ((693, 754), 'logging.Formatter', 'logging.Formatter', (['"""%(name)-12s: %(levelname)-8s %(message)s"""'], {}), "('%(name)-12s: %(levelname)-8s %(message)s')\n", (710, 754), False, 'import logging\n'), ((803, 824), 'logging.getLogger', 'logging.getLogger', (['""""""'], {}), "('')\n", (820, 824), False, 'import logging\n')]