本文整理汇总了Python中baseplate.Baseplate.configure_logging方法的典型用法代码示例。如果您正苦于以下问题:Python Baseplate.configure_logging方法的具体用法?Python Baseplate.configure_logging怎么用?Python Baseplate.configure_logging使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类baseplate.Baseplate
的用法示例。
在下文中一共展示了Baseplate.configure_logging方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_wsgi_app
# 需要导入模块: from baseplate import Baseplate [as 别名]
# 或者: from baseplate.Baseplate import configure_logging [as 别名]
def make_wsgi_app(app_config):
cfg = config.parse_config(app_config)
signer = MessageSigner(cfg.ads_tracking.click_secret)
metrics_client = make_metrics_client(app_config)
baseplate = Baseplate()
baseplate.configure_logging()
baseplate.configure_metrics(metrics_client)
baseplate.add_to_context("events", events.EventQueue("production"))
baseplate.add_to_context("events_test", events.EventQueue("test"))
configurator = Configurator(settings=app_config)
baseplate_configurator = BaseplateConfigurator(baseplate)
configurator.include(baseplate_configurator.includeme)
controller = TrackingService(
signer=signer,
)
configurator.add_route("health", "/health", request_method="GET")
configurator.add_view(
controller.is_healthy, route_name="health", renderer="json")
configurator.add_route("click", "/click", request_method="GET")
configurator.add_view(
controller.track_click, route_name="click", renderer="json")
return configurator.make_wsgi_app()
示例2: make_wsgi_app
# 需要导入模块: from baseplate import Baseplate [as 别名]
# 或者: from baseplate.Baseplate import configure_logging [as 别名]
def make_wsgi_app(app_config):
cfg = config.parse_config(app_config, {
"session": {
"secret": config.Base64,
}
})
# configure pyramid
configurator = Configurator(settings=app_config)
configurator.include("pyramid_jinja2")
configurator.set_default_csrf_options(require_csrf=True)
configurator.set_session_factory(SignedCookieSessionFactory(cfg.session.secret))
authn_policy = RemoteUserAuthenticationPolicy(environ_key="HTTP_AUTHENTICATED_USER")
authz_policy = ACLAuthorizationPolicy()
configurator.set_authentication_policy(authn_policy)
configurator.set_authorization_policy(authz_policy)
configurator.add_request_method(get_authenticated_user, "user", reify=True)
configurator.add_static_view(name="static", path="condor:static/")
configurator.add_route("home", "/")
configurator.add_route("polls", "/polls")
configurator.add_route("poll", "/polls/{id:\d+}")
configurator.scan("condor.views")
# configure baseplate
metrics_client = make_metrics_client(app_config)
baseplate = Baseplate()
baseplate.configure_logging()
baseplate.configure_metrics(metrics_client)
engine = engine_from_config(app_config, prefix="database.")
baseplate.add_to_context("db", SQLAlchemySessionContextFactory(engine))
baseplate_configurator = BaseplateConfigurator(baseplate)
configurator.include(baseplate_configurator.includeme)
return configurator.make_wsgi_app()
示例3: Globals
# 需要导入模块: from baseplate import Baseplate [as 别名]
# 或者: from baseplate.Baseplate import configure_logging [as 别名]
#.........这里部分代码省略.........
``app_conf``
The same ``kw`` dictionary used throughout
``config/middleware.py`` namely, the variables from the
section in the config file for your application.
``extra``
The configuration returned from ``load_config`` in
``config/middleware.py`` which may be of use in the setup of
your global variables.
"""
global_conf.setdefault("debug", False)
# reloading site ensures that we have a fresh sys.path to build our
# working set off of. this means that forked worker processes won't get
# the sys.path that was current when the master process was spawned
# meaning that new plugins will be picked up on regular app reload
# rather than having to restart the master process as well.
reload(site)
self.pkg_resources_working_set = pkg_resources.WorkingSet()
self.config = ConfigValueParser(global_conf)
self.config.add_spec(self.spec)
self.plugins = PluginLoader(self.pkg_resources_working_set,
self.config.get("plugins", []))
self.stats = Stats(self.config.get('statsd_addr'),
self.config.get('statsd_sample_rate'))
self.startup_timer = self.stats.get_timer("app_startup")
self.startup_timer.start()
self.baseplate = Baseplate()
self.baseplate.configure_logging()
self.baseplate.register(R2BaseplateObserver())
self.paths = paths
self.running_as_script = global_conf.get('running_as_script', False)
# turn on for language support
self.lang = getattr(self, 'site_lang', 'en')
self.languages, self.lang_name = get_active_langs(
config, default_lang=self.lang)
all_languages = self.lang_name.keys()
all_languages.sort()
self.all_languages = all_languages
# set default time zone if one is not set
tz = global_conf.get('timezone', 'UTC')
self.tz = pytz.timezone(tz)
dtz = global_conf.get('display_timezone', tz)
self.display_tz = pytz.timezone(dtz)
self.startup_timer.intermediate("init")
def __getattr__(self, name):
if not name.startswith('_') and name in self.config:
return self.config[name]
else:
raise AttributeError("g has no attr %r" % name)
def setup(self):
self.env = ''