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


Python app_log.error方法代码示例

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


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

示例1: _handle_request_exception

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def _handle_request_exception(self, e):
        if isinstance(e, Finish):
            # Not an error; just finish the request without logging.
            if not self._finished:
                self.finish(*e.args)
            return
        try:
            self.log_exception(*sys.exc_info())
        except Exception:
            # An error here should still get a best-effort send_error()
            # to avoid leaking the connection.
            app_log.error("Error in exception logger", exc_info=True)
        if self._finished:
            # Extra errors after the request has been finished should
            # be logged, but there is no reason to continue to try and
            # send a response.
            return
        if isinstance(e, HTTPError):
            if e.status_code not in httputil.responses and not e.reason:
                gen_log.error("Bad HTTP status code: %d", e.status_code)
                self.send_error(500, exc_info=sys.exc_info())
            else:
                self.send_error(e.status_code, exc_info=sys.exc_info())
        else:
            self.send_error(500, exc_info=sys.exc_info()) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:27,代码来源:web.py

示例2: log_exception

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [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

示例3: headers_received

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def headers_received(self, start_line, headers):
        if start_line.code != 101:
            return super(WebSocketClientConnection, self).headers_received(
                start_line, headers)

        self.headers = headers
        self.protocol = self.get_websocket_protocol()
        self.protocol._process_server_headers(self.key, self.headers)
        self.protocol._receive_frame()

        if self._timeout is not None:
            self.io_loop.remove_timeout(self._timeout)
            self._timeout = None

        self.stream = self.connection.detach()
        self.stream.set_close_callback(self.on_connection_close)
        # Once we've taken over the connection, clear the final callback
        # we set on the http request.  This deactivates the error handling
        # in simple_httpclient that would otherwise interfere with our
        # ability to see exceptions.
        self.final_callback = None

        self.connect_future.set_result(self) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:25,代码来源:websocket.py

示例4: close

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def close(self, exc_info=False):
        """Close this stream.

        If ``exc_info`` is true, set the ``error`` attribute to the current
        exception from `sys.exc_info` (or if ``exc_info`` is a tuple,
        use that instead of `sys.exc_info`).
        """
        if not self.closed():
            if exc_info:
                if not isinstance(exc_info, tuple):
                    exc_info = sys.exc_info()
                if any(exc_info):
                    self.error = exc_info[1]
            if self._read_until_close:
                if (self._streaming_callback is not None and
                        self._read_buffer_size):
                    self._run_read_callback(self._read_buffer_size, True)
                self._read_until_close = False
                self._run_read_callback(self._read_buffer_size, False)
            if self._state is not None:
                self.io_loop.remove_handler(self.fileno())
                self._state = None
            self.close_fd()
            self._closed = True
        self._maybe_run_close_callback() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:27,代码来源:iostream.py

示例5: _handle_connect

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def _handle_connect(self):
        err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
        if err != 0:
            self.error = socket.error(err, os.strerror(err))
            # IOLoop implementations may vary: some of them return
            # an error state before the socket becomes writable, so
            # in that case a connection failure would be handled by the
            # error path in _handle_events instead of here.
            if self._connect_future is None:
                gen_log.warning("Connect error on fd %s: %s",
                                self.socket.fileno(), errno.errorcode[err])
            self.close()
            return
        if self._connect_callback is not None:
            callback = self._connect_callback
            self._connect_callback = None
            self._run_callback(callback)
        if self._connect_future is not None:
            future = self._connect_future
            self._connect_future = None
            future.set_result(self)
        self._connecting = False 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:24,代码来源:iostream.py

示例6: __init__

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def __init__(self, *args, **kwargs):
        """The ``ssl_options`` keyword argument may either be an
        `ssl.SSLContext` object or a dictionary of keywords arguments
        for `ssl.wrap_socket`
        """
        self._ssl_options = kwargs.pop('ssl_options', _client_ssl_defaults)
        super(SSLIOStream, self).__init__(*args, **kwargs)
        self._ssl_accepting = True
        self._handshake_reading = False
        self._handshake_writing = False
        self._ssl_connect_callback = None
        self._server_hostname = None

        # If the socket is already connected, attempt to start the handshake.
        try:
            self.socket.getpeername()
        except socket.error:
            pass
        else:
            # Indirectly start the handshake, which will run on the next
            # IOLoop iteration and then the real IO state will be set in
            # _handle_events.
            self._add_io_state(self.io_loop.WRITE) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:25,代码来源:iostream.py

示例7: _run_callback

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def _run_callback(self, callback):
        """Runs a callback with error handling.

        For use in subclasses.
        """
        try:
            ret = callback()
            if ret is not None:
                from tornado import gen
                # Functions that return Futures typically swallow all
                # exceptions and store them in the Future.  If a Future
                # makes it out to the IOLoop, ensure its exception (if any)
                # gets logged too.
                try:
                    ret = gen.convert_yielded(ret)
                except gen.BadYieldError:
                    # It's not unusual for add_callback to be used with
                    # methods returning a non-None and non-yieldable
                    # result, which should just be ignored.
                    pass
                else:
                    self.add_future(ret, lambda f: f.result())
        except Exception:
            self.handle_callback_exception(callback) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:26,代码来源:ioloop.py

示例8: log_request

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [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

示例9: get_result

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def get_result(self):
        result_list = []
        exc_info = None
        for f in self.children:
            try:
                result_list.append(f.get_result())
            except Exception as e:
                if exc_info is None:
                    exc_info = sys.exc_info()
                else:
                    if not isinstance(e, self.quiet_exceptions):
                        app_log.error("Multiple exceptions in yield list",
                                      exc_info=True)
        if exc_info is not None:
            raise_exc_info(exc_info)
        if self.keys is not None:
            return dict(zip(self.keys, result_list))
        else:
            return list(result_list) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:21,代码来源:gen.py

示例10: _run_read_callback

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def _run_read_callback(self, size, streaming):
        if streaming:
            callback = self._streaming_callback
        else:
            callback = self._read_callback
            self._read_callback = self._streaming_callback = None
            if self._read_future is not None:
                assert callback is None
                future = self._read_future
                self._read_future = None
                future.set_result(self._consume(size))
        if callback is not None:
            assert (self._read_future is None) or streaming
            self._run_callback(callback, self._consume(size))
        else:
            # If we scheduled a callback, we will add the error listener
            # afterwards.  If we didn't, we have to do it now.
            self._maybe_add_error_listener() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:20,代码来源:iostream.py

示例11: set_default_headers

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def set_default_headers(self):
        """复写这个方法可以在请求开始的时候设置HTTP头.

        例如, 在这里可以设置一个自定义 ``Server`` 头. 注意在一般的
        请求过程流里可能不会实现你预期的效果, 因为头部可能在错误处
        理(error handling)中被重置.
        """
        pass 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:10,代码来源:web.py

示例12: send_error

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def send_error(self, status_code=500, **kwargs):
        """给浏览器发送给定的HTTP 错误码.

        如果 `flush()` 已经被调用, 它是不可能发送错误的, 所以这个方法将终止
        响应. 如果输出已经被写但尚未flush, 它将被丢弃并被错误页代替.

        复写 `write_error()` 来自定义它返回的错误页. 额外的关键字参数将
        被传递给 `write_error`.
        """
        if self._headers_written:
            gen_log.error("Cannot send error response after headers written")
            if not self._finished:
                # If we get an error between writing headers and finishing,
                # we are unlikely to be able to finish due to a
                # Content-Length mismatch. Try anyway to release the
                # socket.
                try:
                    self.finish()
                except Exception:
                    gen_log.error("Failed to flush partial response",
                                  exc_info=True)
            return
        self.clear()

        reason = kwargs.get('reason')
        if 'exc_info' in kwargs:
            exception = kwargs['exc_info'][1]
            if isinstance(exception, HTTPError) and exception.reason:
                reason = exception.reason
        self.set_status(status_code, reason=reason)
        try:
            self.write_error(status_code, **kwargs)
        except Exception:
            app_log.error("Uncaught exception in write_error", exc_info=True)
        if not self._finished:
            self.finish() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:38,代码来源:web.py

示例13: _get_cached_version

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def _get_cached_version(cls, abs_path):
        with cls._lock:
            hashes = cls._static_hashes
            if abs_path not in hashes:
                try:
                    hashes[abs_path] = cls.get_content_version(abs_path)
                except Exception:
                    gen_log.error("Could not open static file %r", abs_path)
                    hashes[abs_path] = None
            hsh = hashes.get(abs_path)
            if hsh:
                return hsh
        return None 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:15,代码来源:web.py

示例14: _called

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def _called(self):
        self._active = False
        self._reactor._removeDelayedCall(self)
        try:
            self._func()
        except:
            app_log.error("_called caught exception", exc_info=True) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:9,代码来源:twisted.py

示例15: _invoke_callback

# 需要导入模块: from tornado.log import app_log [as 别名]
# 或者: from tornado.log.app_log import error [as 别名]
def _invoke_callback(self, fd, events):
        if fd not in self._fds:
            return
        (reader, writer) = self._fds[fd]
        if reader:
            err = None
            if reader.fileno() == -1:
                err = error.ConnectionLost()
            elif events & IOLoop.READ:
                err = log.callWithLogger(reader, reader.doRead)
            if err is None and events & IOLoop.ERROR:
                err = error.ConnectionLost()
            if err is not None:
                self.removeReader(reader)
                reader.readConnectionLost(failure.Failure(err))
        if writer:
            err = None
            if writer.fileno() == -1:
                err = error.ConnectionLost()
            elif events & IOLoop.WRITE:
                err = log.callWithLogger(writer, writer.doWrite)
            if err is None and events & IOLoop.ERROR:
                err = error.ConnectionLost()
            if err is not None:
                self.removeWriter(writer)
                writer.writeConnectionLost(failure.Failure(err)) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:28,代码来源:twisted.py


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