def test_access_log_json_format(self):
        """Test the exact JSON format of access logs"""
        # Set up environment for JSON format
        with patch.dict('os.environ', {
            'MARQO_LOG_LEVEL': 'info',
            'MARQO_LOG_FORMAT': 'json'
        }):
            importlib.reload(marqo_logging)

            # Get the access logger and its handler
            access_logger = logging.getLogger('uvicorn.access')
            access_handler = access_logger.handlers[0]

            # Replace the stream object of the handler
            stream = io.StringIO()
            access_handler.stream = stream

            access_logger.info('%s - "%s %s HTTP/%s" %d',
                               "127.0.0.1:30000", "GET", "/api/v1/search", "1.1", 200)

            # Verify JSON output
            output = stream.getvalue()
            import json
            try:
                log_data = json.loads(output)
                self.assertEqual(log_data['level'], 'INFO')
                self.assertEqual(log_data['client_addr'], '127.0.0.1:30000')
                self.assertEqual(log_data['request_line'], 'GET /api/v1/search HTTP/1.1')
                self.assertEqual(log_data['status_code'], "200 OK")
                self.assertIn('timestamp', log_data)
                self.assertIn('process', log_data)
            except json.JSONDecodeError:
                self.fail("Output is not valid JSON")
Test the exact JSON format of access logs
tests/unit_tests/marqo/test_logging.py