

def create_logger(app):
    "Creates a logger for the given application.  This logger works\n    similar to a regular Python logger but changes the effective logging\n    level based on the application's debug flag.  Furthermore this\n    function also removes all attached handlers in case there was a\n    logger with the log name before.\n    "
    Logger = getLoggerClass()

    class DebugLogger(Logger):

        def getEffectiveLevel(self):
            if ((self.level == 0) and app.debug):
                return DEBUG
            return Logger.getEffectiveLevel(self)

    class DebugHandler(StreamHandler):

        def emit(self, record):
            if (app.debug and _should_log_for(app, 'debug')):
                StreamHandler.emit(self, record)

    class ProductionHandler(StreamHandler):

        def emit(self, record):
            if ((not app.debug) and _should_log_for(app, 'production')):
                StreamHandler.emit(self, record)
    debug_handler = DebugHandler()
    debug_handler.setLevel(DEBUG)
    debug_handler.setFormatter(Formatter(DEBUG_LOG_FORMAT))
    prod_handler = ProductionHandler(_proxy_stream)
    prod_handler.setLevel(ERROR)
    prod_handler.setFormatter(Formatter(PROD_LOG_FORMAT))
    logger = getLogger(app.logger_name)
    del logger.handlers[:]
    logger.__class__ = DebugLogger
    logger.addHandler(debug_handler)
    logger.addHandler(prod_handler)
    return logger

dataset/ETHPy150Open pallets/flask/flask/logging.py create_logger/original