Пример #1
0
    def setLoggingLevel():
        """Set Logging Level Based on Feature Flag

        This uses LaunchDarkly to update the logging level dynamically.
        Before each request runs, we check the current logging level and
        it does not match, we update it to the new value.

        Logging levels are integer values based on the standard Logging library
        in python: https://docs.python.org/3/library/logging.html#logging-levels

        This is an operational feature flag.
        """
        from flask import request

        logLevel = app.ldclient.variation("set-logging-level",
                                          getLdMachineUser(request),
                                          logging.INFO)

        app.logger.info("Log level is {0}".format(logLevel))

        # set app
        app.logger.setLevel(logLevel)
        # set werkzeug
        logging.getLogger("werkzeug").setLevel(logLevel)
        # set root
        logging.getLogger().setLevel(logLevel)
Пример #2
0
 def __call__(self):
     return ldclient.get().variation('disable-caching', getLdMachineUser(), True)
Пример #3
0
def caching_disabled():
    return admin_ldclient.variation('disable-caching', getLdMachineUser(),
                                    True)
Пример #4
0
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy

from app.config import config
from app.util import getLdMachineUser
from app.cli import deploy_command

db = SQLAlchemy()
migrate = Migrate()
bootstrap =  Bootstrap()
login = LoginManager()
cache = Cache(config={'CACHE_TYPE': 'redis'})

# Operational Feature Flags
CACHE_TIMEOUT = lambda : ldclient.get().variation('cache-timeout', getLdMachineUser(), 50)

class CachingDisabled:
    def __call__(self):
        return ldclient.get().variation('disable-caching', getLdMachineUser(), True)

def create_app(config_name):
    """Flask application factory.

    :param config_name: Flask Configuration
    
    :type config_name: app.config class 

    :returns: a flask application
    """
    app = Flask(__name__)
Пример #5
0
from flask_caching import Cache

from app.admin_ldclient import admin_ldclient
from app.util import getLdMachineUser

cache = Cache()

CACHE_TIMEOUT = lambda: admin_ldclient.variation('cache-timeout',
                                                 getLdMachineUser(), 50)


def caching_disabled():
    return admin_ldclient.variation('disable-caching', getLdMachineUser(),
                                    True)