当前位置: 首页>>代码示例>>Python>>正文


Python app_log.warning方法代码示例

本文整理汇总了Python中tornado.log.app_log.warning方法的典型用法代码示例。如果您正苦于以下问题:Python app_log.warning方法的具体用法?Python app_log.warning怎么用?Python app_log.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.log.app_log的用法示例。


在下文中一共展示了app_log.warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: log_exception

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def log_exception(self, typ, value, tb):
        """复写来自定义未捕获异常的日志.

        默认情况下 `HTTPError` 的日志实例作为警告(warning)没有堆栈追踪(在
        ``tornado.general`` logger), 其他作为错误(error)的异常带有堆栈
        追踪(在 ``tornado.application`` logger).

        .. versionadded:: 3.1
        """
        if isinstance(value, HTTPError):
            if value.log_message:
                format = "%d %s: " + value.log_message
                args = ([value.status_code, self._request_summary()] +
                        list(value.args))
                gen_log.warning(format, *args)
        else:
            app_log.error("Uncaught exception %s\n%r", self._request_summary(),
                          self.request, exc_info=(typ, value, tb)) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:20,代码来源:web.py

示例2: log_request

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def log_request(self, handler):
        """写一个完成的HTTP 请求到日志中.

        默认情况下会写到python 根(root)logger. 要改变这种行为
        无论是子类应用和复写这个方法, 或者传递一个函数到应用的
        设置字典中作为 ``log_function``.
        """
        if "log_function" in self.settings:
            self.settings["log_function"](handler)
            return
        if handler.get_status() < 400:
            log_method = access_log.info
        elif handler.get_status() < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * handler.request.request_time()
        log_method("%d %s %.2fms", handler.get_status(),
                   handler._request_summary(), request_time) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:21,代码来源:web.py

示例3: log_exception

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def log_exception(self, typ, value, tb):
        """Override to customize logging of uncaught exceptions.

        By default logs instances of `HTTPError` as warnings without
        stack traces (on the ``tornado.general`` logger), and all
        other exceptions as errors with stack traces (on the
        ``tornado.application`` logger).

        .. versionadded:: 3.1
        """
        if isinstance(value, HTTPError):
            if value.log_message:
                format = "%d %s: " + value.log_message
                args = ([value.status_code, self._request_summary()] +
                        list(value.args))
                gen_log.warning(format, *args)
        else:
            app_log.error("Uncaught exception %s\n%r", self._request_summary(),
                          self.request, exc_info=(typ, value, tb)) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:21,代码来源:web.py

示例4: log_request

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def log_request(self, handler):
        """Writes a completed HTTP request to the logs.

        By default writes to the python root logger.  To change
        this behavior either subclass Application and override this method,
        or pass a function in the application settings dictionary as
        ``log_function``.
        """
        if "log_function" in self.settings:
            self.settings["log_function"](handler)
            return
        if handler.get_status() < 400:
            log_method = access_log.info
        elif handler.get_status() < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * handler.request.request_time()
        log_method("%d %s %.2fms", handler.get_status(),
                   handler._request_summary(), request_time) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:22,代码来源:web.py

示例5: reset_is_running_on_all_spider

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def reset_is_running_on_all_spider( coll_model ) :
	"""
	reset is_running on all spiders to avoid errors if app shut down while one spider was running 
	"""

	print ()

	app_log.warning('>>> reset_is_running_on_all_spider ... ')
	
	# find if any spider was running
	running_spiders = coll_model.find({"scraper_log.is_running" : True})
	app_log.info(">>> running_spiders : \n %s" , list(running_spiders) )

	coll_model.update_many({'scraper_log.is_running' : True }, {"$set": {'scraper_log.is_running' : False }})

	# if list(running_spiders) != [] : 

	# 	app_log.warning('>>> reset_is_running_on_all_spider / some spiders were blocked in is_running == True ... ')
	# 	app_log.warning('>>> spiders are : \n %s', pformat(list(running_spiders)) )

	# 	coll_model.update({"scraper_log.is_running":True}, {"$set" : {"scraper_log.is_running" : False }})
	
	# print 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:25,代码来源:main.py

示例6: backup_mongo_collection

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def backup_mongo_collection(coll, filepath) :
	"""
	dumps all documents in collection in _backups_collections 
	"""

	app_log.warning('>>> backup_mongo_collection ... ')

	cursor 		= coll.find({})
	backup_file = open(filepath, "w")
	backup_file.write('[')
	for document in cursor:
		backup_file.write(json.dumps(document,indent=4, default=json_util.default))
		backup_file.write(',')
	backup_file.write(']')

### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ###


### MAIN TORNADO APPLICATION WRAPPER 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:21,代码来源:main.py

示例7: __init__

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def __init__(self, **kwargs) :

		print
		app_log.warning("== UserClass ... ")

		app_log.warning("== UserClass / fields from USER_CORE_FIELDS ... ")
		for user_field in USER_CORE_FIELDS :
			app_log.warning("== UserClass / user_field : %s", user_field)
			self.__dict__[user_field] = ""

		app_log.warning("== UserClass / fields from **kwargs ...")
		for k, v in kwargs.items():
			# print "{} : {}".format(k,v)
			app_log.warning("== UserClass / %s : %s ...", k, v)
			try :
				self.__dict__[k] = v
			except : 
				pass

		print 

	### TO DO : hash password 
开发者ID:entrepreneur-interet-general,项目名称:OpenScraper,代码行数:24,代码来源:core_classes.py

示例8: add_handlers

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def add_handlers(self, host_pattern, host_handlers):
        """添加给定的handler到我们的handler表.

        Host 模式将按照它们的添加顺序进行处理.
        所有匹配模式将被考虑.
        """
        if not host_pattern.endswith("$"):
            host_pattern += "$"
        handlers = []
        # The handlers with the wildcard host_pattern are a special
        # case - they're added in the constructor but should have lower
        # precedence than the more-precise handlers added later.
        # If a wildcard handler group exists, it should always be last
        # in the list, so insert new groups just before it.
        if self.handlers and self.handlers[-1][0].pattern == '.*$':
            self.handlers.insert(-1, (re.compile(host_pattern), handlers))
        else:
            self.handlers.append((re.compile(host_pattern), handlers))

        for spec in host_handlers:
            if isinstance(spec, (tuple, list)):
                assert len(spec) in (2, 3, 4)
                spec = URLSpec(*spec)
            handlers.append(spec)
            if spec.name:
                if spec.name in self.named_handlers:
                    app_log.warning(
                        "Multiple handlers named %s; replacing previous value",
                        spec.name)
                self.named_handlers[spec.name] = spec 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:32,代码来源:web.py

示例9: _decode_signed_value_v1

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def _decode_signed_value_v1(secret, name, value, max_age_days, clock):
    parts = utf8(value).split(b"|")
    if len(parts) != 3:
        return None
    signature = _create_signature_v1(secret, name, parts[0], parts[1])
    if not _time_independent_equals(parts[2], signature):
        gen_log.warning("Invalid cookie signature %r", value)
        return None
    timestamp = int(parts[1])
    if timestamp < clock() - max_age_days * 86400:
        gen_log.warning("Expired cookie %r", value)
        return None
    if timestamp > clock() + 31 * 86400:
        # _cookie_signature does not hash a delimiter between the
        # parts of the cookie, so an attacker could transfer trailing
        # digits from the payload to the timestamp without altering the
        # signature.  For backwards compatibility, sanity-check timestamp
        # here instead of modifying _cookie_signature.
        gen_log.warning("Cookie timestamp in future; possible tampering %r",
                        value)
        return None
    if parts[1].startswith(b"0"):
        gen_log.warning("Tampered cookie %r", value)
        return None
    try:
        return base64.b64decode(parts[0])
    except Exception:
        return None 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:30,代码来源:web.py

示例10: log_exception

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def log_exception(self, typ, value, tb):
            if isinstance(value, PermissionError):
                app_log.warning('custom logging for PermissionError: %s',
                                value.args[0])
            else:
                RequestHandler.log_exception(self, typ, value, tb) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:8,代码来源:web_test.py

示例11: process_rule

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def process_rule(self, rule: "Rule") -> "Rule":
        rule = super(ReversibleRuleRouter, self).process_rule(rule)

        if rule.name:
            if rule.name in self.named_rules:
                app_log.warning(
                    "Multiple handlers named %s; replacing previous value", rule.name
                )
            self.named_rules[rule.name] = rule

        return rule 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:13,代码来源:routing.py

示例12: log_exception

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def log_exception(self, typ, value, tb):
            if isinstance(value, PermissionError):
                app_log.warning("custom logging for PermissionError: %s", value.args[0])
            else:
                RequestHandler.log_exception(self, typ, value, tb) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:7,代码来源:web_test.py

示例13: decode_signed_value

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def decode_signed_value(secret, name, value, max_age_days=31):
    if not value:
        return None
    parts = utf8(value).split(b"|")
    if len(parts) != 3:
        return None
    signature = _create_signature(secret, name, parts[0], parts[1])
    if not _time_independent_equals(parts[2], signature):
        gen_log.warning("Invalid cookie signature %r", value)
        return None
    timestamp = int(parts[1])
    if timestamp < time.time() - max_age_days * 86400:
        gen_log.warning("Expired cookie %r", value)
        return None
    if timestamp > time.time() + 31 * 86400:
        # _cookie_signature does not hash a delimiter between the
        # parts of the cookie, so an attacker could transfer trailing
        # digits from the payload to the timestamp without altering the
        # signature.  For backwards compatibility, sanity-check timestamp
        # here instead of modifying _cookie_signature.
        gen_log.warning("Cookie timestamp in future; possible tampering %r", value)
        return None
    if parts[1].startswith(b"0"):
        gen_log.warning("Tampered cookie %r", value)
        return None
    try:
        return base64.b64decode(parts[0])
    except Exception:
        return None 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:31,代码来源:web.py

示例14: process_rule

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def process_rule(self, rule):
        rule = super(ReversibleRuleRouter, self).process_rule(rule)

        if rule.name:
            if rule.name in self.named_rules:
                app_log.warning(
                    "Multiple handlers named %s; replacing previous value",
                    rule.name)
            self.named_rules[rule.name] = rule

        return rule 
开发者ID:tp4a,项目名称:teleport,代码行数:13,代码来源:routing.py

示例15: fetch_impl

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import warning [as 别名]
def fetch_impl(self, request, response_callback):
        urlinfo = urlparse(request.url)
        host = urlinfo.hostname
        if host not in self.hosts:
            app_log.warning("Not mocking request to %s", request.url)
            return super().fetch_impl(request, response_callback)
        paths = self.hosts[host]
        response = None
        for path_spec, handler in paths:
            if isinstance(path_spec, str):
                if path_spec == urlinfo.path:
                    response = handler(request)
                    break
            else:
                if path_spec.match(urlinfo.path):
                    response = handler(request)
                    break

        if response is None:
            response = HTTPResponse(request=request, code=404, reason=request.url)
        elif isinstance(response, int):
            response = HTTPResponse(request=request, code=response)
        elif isinstance(response, bytes):
            response = HTTPResponse(request=request, code=200,
                buffer=BytesIO(response),
            )
        elif isinstance(response, str):
            response = HTTPResponse(request=request, code=200,
                buffer=BytesIO(response.encode('utf8')),
            )
        elif isinstance(response, (dict, list)):
            response = HTTPResponse(request=request, code=200,
                buffer=BytesIO(json.dumps(response).encode('utf8')),
                headers={'Content-Type': 'application/json'},
            )

        response_callback(response) 
开发者ID:jupyterhub,项目名称:oauthenticator,代码行数:39,代码来源:mocks.py


注:本文中的tornado.log.app_log.warning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。