當前位置: 首頁>>代碼示例>>Python>>正文


Python access_log.warning方法代碼示例

本文整理匯總了Python中tornado.log.access_log.warning方法的典型用法代碼示例。如果您正苦於以下問題:Python access_log.warning方法的具體用法?Python access_log.warning怎麽用?Python access_log.warning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tornado.log.access_log的用法示例。


在下文中一共展示了access_log.warning方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: log_exception

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_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 access_log [as 別名]
# 或者: from tornado.log.access_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_request

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_log import warning [as 別名]
def log_request(self, handler: RequestHandler) -> None:
        """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:opendevops-cn,項目名稱:opendevops,代碼行數:26,代碼來源:web.py

示例4: log_exception

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_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

示例5: log_request

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_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

示例6: add_handlers

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_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

示例7: _decode_signed_value_v1

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_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

示例8: _log

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_log import warning [as 別名]
def _log(self, status_code, request):
        if status_code < 400:
            log_method = access_log.info
        elif status_code < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * request.request_time()
        summary = request.method + " " + request.uri + " (" + \
            request.remote_ip + ")"
        log_method("%d %s %.2fms", status_code, summary, request_time) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:13,代碼來源:wsgi.py

示例9: log_exception

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_log import warning [as 別名]
def log_exception(
        self,
        typ: "Optional[Type[BaseException]]",
        value: Optional[BaseException],
        tb: Optional[TracebackType],
    ) -> None:
        """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(  # type: ignore
                "Uncaught exception %s\n%r",
                self._request_summary(),
                self.request,
                exc_info=(typ, value, tb),
            ) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:29,代碼來源:web.py

示例10: _decode_signed_value_v1

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_log import warning [as 別名]
def _decode_signed_value_v1(
    secret: Union[str, bytes],
    name: str,
    value: bytes,
    max_age_days: int,
    clock: Callable[[], float],
) -> Optional[bytes]:
    parts = utf8(value).split(b"|")
    if len(parts) != 3:
        return None
    signature = _create_signature_v1(secret, name, parts[0], parts[1])
    if not hmac.compare_digest(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:opendevops-cn,項目名稱:opendevops,代碼行數:35,代碼來源:web.py

示例11: _log

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_log import warning [as 別名]
def _log(self, status_code: int, request: httputil.HTTPServerRequest) -> None:
        if status_code < 400:
            log_method = access_log.info
        elif status_code < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * request.request_time()
        assert request.method is not None
        assert request.uri is not None
        summary = request.method + " " + request.uri + " (" + request.remote_ip + ")"
        log_method("%d %s %.2fms", status_code, summary, request_time) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:14,代碼來源:wsgi.py

示例12: decode_signed_value

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_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

示例13: log_request

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_log import warning [as 別名]
def log_request(handler):
    try:
        request = handler.request
        location_info = referer_info = user_agent_info = ''
        status_code = handler.get_status()
        if status_code < 400:
            log_method = access_log.info
            if status_code in (301, 302, 307):
                location = handler._headers.get('Location')
                if location:
                    location_info = '\n\tLocation: ' + location
        elif status_code < 500:
            log_method = access_log.warning
            headers = request.headers
            referer = headers.get('Referer')
            if referer:
                referer = referer.replace('"', '')
                referer_info = '\n\tReferer url: ' + referer
            user_agent = headers.get('User-Agent')
            if user_agent:
                user_agent = user_agent.replace('"', '')
                user_agent_info = '\n\tUser agent: ' + user_agent
        else:
            log_method = access_log.error

        request_time = request.request_time()
        log_method("%d %s %.2fms%s%s%s", status_code,
                   handler._request_summary(), request_time * 1000.0,
                   location_info, referer_info, user_agent_info)
    except Exception:
        logging.exception('failed to log request') 
開發者ID:keakon,項目名稱:Doodle,代碼行數:33,代碼來源:logger.py

示例14: _log

# 需要導入模塊: from tornado.log import access_log [as 別名]
# 或者: from tornado.log.access_log import warning [as 別名]
def _log(self, status_code, request):
        if status_code < 400:
            log_method = access_log.info
        elif status_code < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error

        timestamp = ut.timestamp()
        request_time = 1000.0 * request.request_time()
        log_method(
            "WALL=%s STATUS=%s METHOD=%s URL=%s IP=%s TIME=%.2fms",
            timestamp,
            status_code, request.method,
            request.uri, request.remote_ip, request_time) 
開發者ID:Erotemic,項目名稱:ibeis,代碼行數:17,代碼來源:app.py


注:本文中的tornado.log.access_log.warning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。