def __init__(self, uris=None, resources=None, authenticator=None, auth_spaces=None, cors_affordancesets=None, settings=None, logger=None, debug_flags=_debug.DEBUG_DEFAULT, stop_on_del=True): self._cors_affordancesets = \ _cors.CorsAffordanceSetMap(cors_affordancesets) self.current_request = None self.current_request_resource = None self.debug_flags = debug_flags self._logger = logger or _logging.getLogger('bedframe') self._resources = _resources.WebResourceMap(resources) self._settings = settings or _settings.Settings('bedframe') self.stop_on_del = stop_on_del self._uris = tuple(uris or ()) auth_spaces = _auth.SpaceMap(auth_spaces) if authenticator: if auth_spaces: authenticator.auth_spaces.clear() authenticator.auth_spaces.update(auth_spaces) self._authenticator = authenticator else: self._authenticator = _auth.Authenticator(service=self, spaces=auth_spaces) # FIXME: parametrize better sentry_server = self.settings.value('sentry/server') self._sentryclient = _sentry.Client(sentry_server) \ if sentry_server is not None else None self._set_status('stopped')
"""Tornado support, common components""" __copyright__ = "Copyright (C) 2014 Ivan D Vasin" __docformat__ = "restructuredtext" import spruce.logging as _logging TORNADO_LOGGER = _logging.getLogger("tornado") def tornado_log_request(handler): if handler.get_status() < 400: log_method = TORNADO_LOGGER.info elif handler.get_status() < 500: log_method = TORNADO_LOGGER.warning else: log_method = TORNADO_LOGGER.error log_method( "{:d} {} {:.2f} ms".format(handler.get_status(), handler._request_summary(), handler.request.request_time()) )
_bedframe.DebugFlagSet.flag_name(flag).lower()) _DEBUG_FLAGS_BY_ARGVALUE = \ _odict([('secure', _bedframe.DEBUG_SECURE), ('default', _bedframe.DEBUG_DEFAULT), ('full', _bedframe.DEBUG_FULL), ('exc_secure', _bedframe.DEBUG_EXC_SECURE), ('exc_default', _bedframe.DEBUG_EXC_DEFAULT), ('exc_full', _bedframe.DEBUG_EXC_FULL), ]) _DEBUG_FLAGS_BY_ARGVALUE.update([(_debug_flag_argname(flag), flag) for flag in _bedframe.DebugFlagSet.valid_flags()]) _logger = _logging.getLogger() _LOGGING_FORMAT = '%(levelname)s: %(message)s' _LOGLEVELS_BY_ARGVALUE = _odict([('critical', _logging.CRITICAL), ('error', _logging.ERROR), ('warning', _logging.WARNING), ('info', _logging.INFO), ('debug', _logging.DEBUG), ('insecure', _logging.INSECURE), ]) if __name__ == '__main__': main()