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


Python log.app_log方法代码示例

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


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

示例1: test_multi_exceptions

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_multi_exceptions(self):
        with ExpectLog(app_log, "Multiple exceptions in yield list"):
            with self.assertRaises(RuntimeError) as cm:
                yield gen.Multi([self.async_exception(RuntimeError("error 1")),
                                 self.async_exception(RuntimeError("error 2"))])
        self.assertEqual(str(cm.exception), "error 1")

        # With only one exception, no error is logged.
        with self.assertRaises(RuntimeError):
            yield gen.Multi([self.async_exception(RuntimeError("error 1")),
                             self.async_future(2)])

        # Exception logging may be explicitly quieted.
        with self.assertRaises(RuntimeError):
            yield gen.Multi([self.async_exception(RuntimeError("error 1")),
                             self.async_exception(RuntimeError("error 2"))],
                            quiet_exceptions=RuntimeError) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:19,代码来源:gen_test.py

示例2: test_multi_future_exceptions

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_multi_future_exceptions(self):
        with ExpectLog(app_log, "Multiple exceptions in yield list"):
            with self.assertRaises(RuntimeError) as cm:
                yield [self.async_exception(RuntimeError("error 1")),
                       self.async_exception(RuntimeError("error 2"))]
        self.assertEqual(str(cm.exception), "error 1")

        # With only one exception, no error is logged.
        with self.assertRaises(RuntimeError):
            yield [self.async_exception(RuntimeError("error 1")),
                   self.async_future(2)]

        # Exception logging may be explicitly quieted.
        with self.assertRaises(RuntimeError):
            yield gen.multi_future(
                [self.async_exception(RuntimeError("error 1")),
                 self.async_exception(RuntimeError("error 2"))],
                quiet_exceptions=RuntimeError) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:20,代码来源:gen_test.py

示例3: _read_chunked_body

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def _read_chunked_body(self, delegate):
        # TODO: "chunk extensions" http://tools.ietf.org/html/rfc2616#section-3.6.1
        total_size = 0
        while True:
            chunk_len = yield self.stream.read_until(b"\r\n", max_bytes=64)
            chunk_len = int(chunk_len.strip(), 16)
            if chunk_len == 0:
                return
            total_size += chunk_len
            if total_size > self._max_body_size:
                raise httputil.HTTPInputError("chunked body too large")
            bytes_to_read = chunk_len
            while bytes_to_read:
                chunk = yield self.stream.read_bytes(
                    min(bytes_to_read, self.params.chunk_size), partial=True)
                bytes_to_read -= len(chunk)
                if not self._write_finished or self.is_client:
                    with _ExceptionLoggingContext(app_log):
                        ret = delegate.data_received(chunk)
                        if ret is not None:
                            yield ret
            # chunk ends with \r\n
            crlf = yield self.stream.read_bytes(2)
            assert crlf == b"\r\n" 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:26,代码来源:http1connection.py

示例4: init_logging

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def init_logging(self):
        """Initialize logging"""
        # This prevents double log messages because tornado use a root logger that
        # self.log is a child of. The logging module dipatches log messages to a log
        # and all of its ancenstors until propagate is set to False.
        self.log.propagate = False

        _formatter = self._log_formatter_cls(
            fmt=self.log_format,
            datefmt=self.log_datefmt,
        )

        # hook up tornado 3's loggers to our app handlers
        for log in (app_log, access_log, gen_log):
            # ensure all log statements identify the application they come from
            log.name = self.log.name
        logger = logging.getLogger('tornado')
        logger.propagate = True
        logger.parent = self.log
        logger.setLevel(self.log.level) 
开发者ID:jupyterhub,项目名称:hubshare,代码行数:22,代码来源:app.py

示例5: __aenter__

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def __aenter__(self):
        await self.hub.initialize([])
        await self.hub.start()

        # alembic turns off all logs, reenable them for the tests
        import logging
        from tornado.log import app_log, access_log, gen_log

        logs = [app_log, access_log, gen_log, logging.getLogger("DaskGateway")]
        for log in logs:
            log.disabled = False

        # Disable curl http client for easier testing
        from tornado.httpclient import AsyncHTTPClient

        AsyncHTTPClient.configure("tornado.simple_httpclient.SimpleAsyncHTTPClient") 
开发者ID:dask,项目名称:dask-gateway,代码行数:18,代码来源:test_auth.py

示例6: test_handle_stream_coroutine_logging

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_handle_stream_coroutine_logging(self):
        # handle_stream may be a coroutine and any exception in its
        # Future will be logged.
        class TestServer(TCPServer):
            @gen.coroutine
            def handle_stream(self, stream, address):
                yield gen.moment
                stream.close()
                1 / 0

        server = client = None
        try:
            sock, port = bind_unused_port()
            with NullContext():
                server = TestServer()
                server.add_socket(sock)
            client = IOStream(socket.socket())
            with ExpectLog(app_log, "Exception in callback"):
                yield client.connect(('localhost', port))
                yield client.read_until_close()
                yield gen.moment
        finally:
            if server is not None:
                server.stop()
            if client is not None:
                client.close() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:28,代码来源:tcpserver_test.py

示例7: test_error_in_on_message

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_error_in_on_message(self):
        ws = yield self.ws_connect('/error_in_on_message')
        ws.write_message('hello')
        with ExpectLog(app_log, "Uncaught exception"):
            response = yield ws.read_message()
        self.assertIs(response, None)
        yield self.close(ws) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:9,代码来源:websocket_test.py

示例8: test_exception_handler

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_exception_handler(self):
        # Make sure we get an error and not a timeout
        with ExpectLog(app_log, "Uncaught exception GET /exception"):
            response = self.fetch('/exception')
        self.assertEqual(500, response.code) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:gen_test.py

示例9: test_multiple_errors

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_multiple_errors(self):
        def fail(message):
            raise Exception(message)
        self.io_loop.add_callback(lambda: fail("error one"))
        self.io_loop.add_callback(lambda: fail("error two"))
        # The first error gets raised; the second gets logged.
        with ExpectLog(app_log, "multiple unhandled exceptions"):
            with self.assertRaises(Exception) as cm:
                self.wait()
        self.assertEqual(str(cm.exception), "error one") 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:testing_test.py

示例10: test_stack_context

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_stack_context(self):
        with ExpectLog(app_log, "Uncaught exception GET /"):
            self.http_client.fetch(self.get_url('/'), self.handle_response)
            self.wait()
        self.assertEqual(self.response.code, 500)
        self.assertTrue(b'got expected exception' in self.response.body) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:8,代码来源:stack_context_test.py

示例11: test_exception_logging

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_exception_logging(self):
        """Uncaught exceptions get logged by the IOLoop."""
        # Use a NullContext to keep the exception from being caught by
        # AsyncTestCase.
        with NullContext():
            self.io_loop.add_callback(lambda: 1 / 0)
            self.io_loop.add_callback(self.stop)
            with ExpectLog(app_log, "Exception in callback"):
                self.wait() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:11,代码来源:ioloop_test.py

示例12: test_exception_logging_future

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_exception_logging_future(self):
        """The IOLoop examines exceptions from Futures and logs them."""
        with NullContext():
            @gen.coroutine
            def callback():
                self.io_loop.add_callback(self.stop)
                1 / 0
            self.io_loop.add_callback(callback)
            with ExpectLog(app_log, "Exception in callback"):
                self.wait() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:ioloop_test.py

示例13: test_exception_logging_native_coro

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def test_exception_logging_native_coro(self):
        """The IOLoop examines exceptions from awaitables and logs them."""
        namespace = exec_test(globals(), locals(), """
        async def callback():
            self.io_loop.add_callback(self.stop)
            1 / 0
        """)
        with NullContext():
            self.io_loop.add_callback(namespace["callback"])
            with ExpectLog(app_log, "Exception in callback"):
                self.wait() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:13,代码来源:ioloop_test.py

示例14: _read_fixed_body

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def _read_fixed_body(self, content_length, delegate):
        while content_length > 0:
            body = yield self.stream.read_bytes(
                min(self.params.chunk_size, content_length), partial=True)
            content_length -= len(body)
            if not self._write_finished or self.is_client:
                with _ExceptionLoggingContext(app_log):
                    ret = delegate.data_received(body)
                    if ret is not None:
                        yield ret 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:http1connection.py

示例15: _read_body_until_close

# 需要导入模块: from tornado import log [as 别名]
# 或者: from tornado.log import app_log [as 别名]
def _read_body_until_close(self, delegate):
        body = yield self.stream.read_until_close()
        if not self._write_finished or self.is_client:
            with _ExceptionLoggingContext(app_log):
                delegate.data_received(body) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:http1connection.py


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