

def setup_logger(logger, fname, stream=True, mode=logging.ERROR):
    'Setup a log file and the logger.  If the given file name is not\n    absolute, put the log file in `ETSConfig.application_home`, if not\n    it will create it where desired.\n\n    Parameters:\n    -----------\n\n    fname -- file name the logger should use.  If this is an absolute\n    path it will create the log file as specified, if not it will put it\n    in `ETSConfig.application_home`.\n\n    stream -- Add a stream handler.\n\n    mode -- the logging mode of the stream handler.\n\n    '
    if (not os.path.isabs(fname)):
        path = os.path.join(ETSConfig.application_home, fname)
    else:
        path = fname
    handlers = logger.handlers
    if (len(handlers) > 1):
        h = handlers[0]
        if (isinstance(h, LogFileHandler) and (h.baseFilename == path)):
            logger.info('Logging handlers already set!  Not duplicating.')
            return
    logger.setLevel(logging.DEBUG)
    handler = LogFileHandler(path)
    handler.setLevel(logging.DEBUG)
    logger.addHandler(handler)
    if stream:
        s = logging.StreamHandler()
        s.setFormatter(FORMATTER)
        s.setLevel(mode)
        logger.addHandler(s)
    logger.info(('*' * 80))
    logger.info("logfile is: '%s'", os.path.abspath(path))
    logger.info(('*' * 80))

dataset/ETHPy150Open enthought/mayavi/mayavi/plugins/app.py setup_logger/original