def get_logger(name=None):
    """Gets a logger for use by Opus. If you want your log entries to also go
    to a separate file, give a name. Otherwise, log messages go to the master
    log"""
    opusroot = logging.getLogger("opus")

    try:
        logdir = settings.LOG_DIR
    except (AttributeError, ImportError):
        logdir = None

    try:
        loglevel = settings.LOG_LEVEL
    except (AttributeError, __HOLE__):
        loglevel = logging.DEBUG

    if isinstance(loglevel, basestring):
            loglevel = {"DEBUG":logging.DEBUG,
                        "INFO": logging.INFO,
                        "WARNING": logging.WARNING,
                        "ERROR": logging.ERROR,
                        "CRITICAL": logging.CRITICAL
                    }[loglevel.upper()]
    

    # If opusroot doesn't have any handlers, add one
    if not opusroot.handlers:
        opusroot.setLevel(loglevel)
        if logdir:
            masterlogfile = os.path.join(logdir, "master.log")
            masterhandler = logging.FileHandler(masterlogfile)
            masterhandler.setFormatter(MyFormatter(color=False))
            opusroot.addHandler(masterhandler)

        try:
            if hasattr(sys.stderr, "isatty"):
                istty = sys.stderr.isatty()
            else:
                istty = False
        except IOError:
            # mod_wsgi raises an error if std streams are accessed
            pass
        else:
            if istty:
                # Add a handler to stderr, using GLORIOUS EXTRA-COLOR!
                colorstderr = logging.StreamHandler()
                colorstderr.setFormatter(MyFormatter(color=True))
                opusroot.addHandler(colorstderr)

    if not name:
        return opusroot

    applogger = logging.getLogger("opus."+name)
    if not applogger.handlers:
        applogger.setLevel(loglevel)
        if logdir:
            # Set up a handler to a separate file
            applogfile = os.path.join(logdir, name+".log")
            h = logging.FileHandler(applogfile)
            h.setFormatter(MyFormatter(color=False))
            applogger.addHandler(h)

    return applogger
dataset/ETHPy150Open bmbouter/Opus/opus/lib/log.py/get_logger