# Buggy code
def includeme(config):
    settings = config.get_settings()

    # Heartbeat registry.
    config.registry.heartbeats = {}

    # Public settings registry.
    config.registry.public_settings = {"batch_max_requests", "readonly"}

    # Setup cornice.
    config.include("cornice")

    # Per-request transaction.
    config.include("pyramid_tm")

    # Add CORS settings to the base cliquet Service class.
    Service.init_from_settings(settings)

    # Setup components.
    for step in aslist(settings["initialization_sequence"]):
        step_func = config.maybe_dotted(step)
        step_func(config)

    # Custom helpers.
    config.add_request_method(follow_subrequest)
    config.add_request_method(
        lambda request: {"id": request.prefixed_userid}, name="get_user_info"
    )
    config.commit()

    # Include cliquet plugins after init, unlike pyramid includes.
    includes = aslist(settings["includes"])
    for app in includes:
        config.include(app)

    # # Show settings to output.
    # for key, value in settings.items():
    #     logger.info('Using %s = %s' % (key, value))

    # Scan views.
    config.scan("cliquet.views")

    # Give sign of life.
    msg = "%(project_name)s %(project_version)s starting."
    logger.info(msg % settings)


# Traceback (AttributeError)
kinto start
event='Backend settings referring to cliquet are DEPRECATED. Please update your kinto.cache_backend setting to kinto.core.cache.memory (was: cliquet.cache.memory).'
event='Backend settings referring to cliquet are DEPRECATED. Please update your kinto.permission_backend setting to kinto.core.permission.memory (was: cliquet.permission.memory).'
event='Backend settings referring to cliquet are DEPRECATED. Please update your kinto.storage_backend setting to kinto.core.storage.memory (was: cliquet.storage.memory).'
Traceback (most recent call last):
File "/home/mathieu/Code/Mozilla/kinto/.venv/bin/kinto", line 9, in <module>
load_entry_point('kinto', 'console_scripts', 'kinto')()
File "/home/mathieu/Code/Mozilla/kinto/kinto/__main__.py", line 97, in main
pserve.main(pserve_argv)
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 60, in main
return command.run()
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 371, in run
global_conf=vars)
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 406, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "/home/mathieu/Code/Mozilla/kinto/.venv/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/home/mathieu/Code/Mozilla/kinto/.venv/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/home/mathieu/Code/Mozilla/kinto/.venv/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/home/mathieu/Code/Mozilla/kinto/.venv/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/home/mathieu/Code/Mozilla/kinto/.venv/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/home/mathieu/Code/Mozilla/kinto/kinto/__init__.py", line 44, in main
default_settings=DEFAULT_SETTINGS)
File "/home/mathieu/Code/Mozilla/kinto/kinto/core/initialization.py", line 553, in initialize
config.include("kinto.core", route_prefix=api_version)
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 800, in include
c(configurator)
File "/home/mathieu/Code/Mozilla/kinto/kinto/core/__init__.py", line 176, in includeme
logger.info(msg % settings)
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/structlog/stdlib.py", line 67, in info
return self._proxy_to_logger('info', event, *args, **kw)
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/structlog/stdlib.py", line 119, in _proxy_to_logger
**event_kw)
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/structlog/_base.py", line 176, in _proxy_to_logger
args, kw = self._process_event(method_name, event, event_kw)
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/structlog/_base.py", line 136, in _process_event
event_dict = proc(self._logger, method_name, event_dict)
File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/structlog/stdlib.py", line 327, in filter_by_level
if logger.isEnabledFor(_NAME_TO_LEVEL[name]):
AttributeError: 'PrintLogger' object has no attribute 'isEnabledFor'

# Fixed code
def includeme(config):
    settings = config.get_settings()

    # Heartbeat registry.
    config.registry.heartbeats = {}

    # Public settings registry.
    config.registry.public_settings = {"batch_max_requests", "readonly"}

    # Directive to declare arbitrary API capabilities.
    def add_api_capability(config, identifier, description="", url="", **kw):
        existing = config.registry.api_capabilities.get(identifier)
        if existing:
            error_msg = "The '%s' API capability was already registered (%s)."
            raise ValueError(error_msg % (identifier, existing))

        capability = dict(description=description, url=url, **kw)
        config.registry.api_capabilities[identifier] = capability

    config.add_directive("add_api_capability", add_api_capability)
    config.registry.api_capabilities = {}

    # Setup cornice.
    config.include("cornice")

    # Per-request transaction.
    config.include("pyramid_tm")

    # Add CORS settings to the base cliquet Service class.
    Service.init_from_settings(settings)

    # Setup components.
    for step in aslist(settings["initialization_sequence"]):
        step_func = config.maybe_dotted(step)
        step_func(config)

    # Custom helpers.
    config.add_request_method(follow_subrequest)
    config.add_request_method(
        lambda request: {"id": request.prefixed_userid}, name="get_user_info"
    )
    config.commit()

    # Include cliquet plugins after init, unlike pyramid includes.
    includes = aslist(settings["includes"])
    for app in includes:
        config.include(app)

    # # Show settings to output.
    # for key, value in settings.items():
    #     logger.info('Using %s = %s' % (key, value))

    # Scan views.
    config.scan("cliquet.views")

    # Give sign of life.
    msg = "%(project_name)s %(project_version)s starting."
    logger.info(msg % settings)