Exemplo n.º 1
0
    def test_no_requests_logging(self):
        """Should not log web requests to avoid an infinite logging loop.

        Do not log any level below warning.
        """
        # Save original state
        handlers_bak = copy(logging.root.handlers)

        logging.root.handlers = []
        socket = Mock()
        LogManager.enable_websocket(socket)
        # Lower logger level simulating logging.ini config
        web_logger = logging.getLogger('werkzeug')
        web_logger.setLevel(logging.DEBUG)

        web_logger.info('should not log')
        self.assertEqual(0, socket.call_count)
        web_logger.warning('should log')
        self.assertEqual(1, socket.emit.call_count)

        # Restore original state
        logging.root.handlers = handlers_bak
Exemplo n.º 2
0
 def test_add_websocket(self):
     """A stream should be used in a handler added to the root logger."""
     socket = Mock()
     handler = LogManager.enable_websocket(socket)
     self.assertIn(handler, logging.root.handlers)
Exemplo n.º 3
0
 def enable_logs(self):
     """Register kytos log and enable the logs."""
     LogManager.load_config_file(self.options.logging, self.options.debug)
     LogManager.enable_websocket(self.api_server.server)
     self.log = logging.getLogger(__name__)
Exemplo n.º 4
0
 def test_add_websocket(self):
     """A stream should be used in a handler added to the root logger."""
     socket = Mock()
     handler = LogManager.enable_websocket(socket)
     self.assertIn(handler, logging.root.handlers)
Exemplo n.º 5
0
 def enable_logs(self):
     """Register kytos log and enable the logs."""
     LogManager.load_config_file(self.options.logging, self.options.debug)
     LogManager.enable_websocket(self.api_server.server)
     self.log = logging.getLogger("controller")