def init_logger(app): log_format = config.get('app', 'LOG_FORMAT') log_root_level = config.get('app', 'LOG_ROOT_LEVEL') log_file_path = config.get('app', 'LOG_FILE_PATH') log_file_log_level = config.get('app', 'LOG_FILE_LOG_LEVEL') init_flask_logger(app, log_format, log_root_level, log_file_path, log_file_log_level) if config.getboolean('app', 'DEBUG'): app.logger.addHandler(logging.StreamHandler(sys.stderr))
def init_app_config(app, config): class CFG(object): pass cfg = CFG() for name in config.options('app'): setattr(cfg, name.upper(), config.get('app', name)) cfg.PORT = config.getint('app', 'PORT') cfg.HOST = config.get('app', 'HOST') cfg.MAX_CONTENT_LENGTH = config.getint('app', 'MAX_CONTENT_LENGTH') cfg.DEBUG = config.getboolean('app', 'DEBUG') server_name = os.getenv('ORANGEAPP_SERVER_URL', '') if server_name: cfg.SERVER_NAME = server_name config.set('app', 'SERVER_NAME', server_name) app.config.from_object(cfg)