We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
prequest doesn't setup logging


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pyramid/scripts/prequest.py`
Content:
```
1 import base64
2 import optparse
3 import sys
4 import textwrap
5 
6 from pyramid.compat import url_unquote
7 from pyramid.request import Request
8 from pyramid.paster import get_app
9 from pyramid.scripts.common import parse_vars
10 
11 def main(argv=sys.argv, quiet=False):
12     command = PRequestCommand(argv, quiet)
13     return command.run()
14 
15 class PRequestCommand(object):
16     description = """\
17     Run a request for the described application.
18 
19     This command makes an artifical request to a web application that uses a
20     PasteDeploy (.ini) configuration file for the server and application.
21 
22     Use "prequest config.ini /path" to request "/path".
23 
24     Use "prequest --method=POST config.ini /path < data" to do a POST with
25     the given request body.
26 
27     Use "prequest --method=PUT config.ini /path < data" to do a
28     PUT with the given request body.
29 
30     Use "prequest --method=PATCH config.ini /path < data" to do a
31     PATCH with the given request body.
32 
33     Use "prequest --method=OPTIONS config.ini /path" to do an
34     OPTIONS request.
35 
36     Use "prequest --method=PROPFIND config.ini /path" to do a
37     PROPFIND request.
38 
39     If the path is relative (doesn't begin with "/") it is interpreted as
40     relative to "/".  The path passed to this script should be URL-quoted.
41     The path can be succeeded with a query string (e.g. `/path?a=1&=b2').
42 
43     The variable "environ['paste.command_request']" will be set to "True" in
44     the request's WSGI environment, so your application can distinguish these
45     calls from normal requests.
46     """
47     usage = "usage: %prog config_uri path_info [args/options]"
48     parser = optparse.OptionParser(
49         usage=usage,
50         description=textwrap.dedent(description)
51         )
52     parser.add_option(
53         '-n', '--app-name',
54         dest='app_name',
55         metavar= 'NAME',
56         help="Load the named application from the config file (default 'main')",
57         type="string",
58         )
59     parser.add_option(
60         '--header',
61         dest='headers',
62         metavar='NAME:VALUE',
63         type='string',
64         action='append',
65         help="Header to add to request (you can use this option multiple times)"
66         )
67     parser.add_option(
68         '-d', '--display-headers',
69         dest='display_headers',
70         action='store_true',
71         help='Display status and headers before the response body'
72         )
73     parser.add_option(
74         '-m', '--method',
75         dest='method',
76         choices=['GET', 'HEAD', 'POST', 'PUT', 'PATCH','DELETE',
77                  'PROPFIND', 'OPTIONS'],
78         type='choice',
79         help='Request method type (GET, POST, PUT, PATCH, DELETE, '
80              'PROPFIND, OPTIONS)',
81         )
82     parser.add_option(
83         '-l', '--login',
84         dest='login',
85         type='string',
86         help='HTTP basic auth username:password pair',
87         )
88 
89     get_app = staticmethod(get_app)
90     stdin = sys.stdin
91 
92     def __init__(self, argv, quiet=False):
93         self.quiet = quiet
94         self.options, self.args = self.parser.parse_args(argv[1:])
95 
96     def out(self, msg): # pragma: no cover
97         if not self.quiet:
98             print(msg)
99 
100     def run(self):
101         if not len(self.args) >= 2:
102             self.out('You must provide at least two arguments')
103             return 2
104         app_spec = self.args[0]
105         path = self.args[1]
106         if not path.startswith('/'):
107             path = '/' + path
108 
109         try:
110             path, qs = path.split('?', 1)
111         except ValueError:
112             qs = ''
113 
114         path = url_unquote(path)
115 
116         headers = {}
117         if self.options.login:
118             enc = base64.b64encode(self.options.login.encode('ascii'))
119             headers['Authorization'] = 'Basic ' + enc.decode('ascii')
120 
121         if self.options.headers:
122             for item in self.options.headers:
123                 if ':' not in item:
124                     self.out(
125                         "Bad --header=%s option, value must be in the form "
126                         "'name:value'" % item)
127                     return 2
128                 name, value = item.split(':', 1)
129                 headers[name] = value.strip()
130 
131         app = self.get_app(app_spec, self.options.app_name,
132                 options=parse_vars(self.args[2:]))
133 
134         request_method = (self.options.method or 'GET').upper()
135 
136         environ = {
137             'REQUEST_METHOD': request_method,
138             'SCRIPT_NAME': '',           # may be empty if app is at the root
139             'PATH_INFO': path,
140             'SERVER_NAME': 'localhost',  # always mandatory
141             'SERVER_PORT': '80',         # always mandatory
142             'SERVER_PROTOCOL': 'HTTP/1.0',
143             'CONTENT_TYPE': 'text/plain',
144             'REMOTE_ADDR':'127.0.0.1',
145             'wsgi.run_once': True,
146             'wsgi.multithread': False,
147             'wsgi.multiprocess': False,
148             'wsgi.errors': sys.stderr,
149             'wsgi.url_scheme': 'http',
150             'wsgi.version': (1, 0),
151             'QUERY_STRING': qs,
152             'HTTP_ACCEPT': 'text/plain;q=1.0, */*;q=0.1',
153             'paste.command_request': True,
154             }
155 
156         if request_method in ('POST', 'PUT', 'PATCH'):
157             environ['wsgi.input'] = self.stdin
158             environ['CONTENT_LENGTH'] = '-1'
159 
160         for name, value in headers.items():
161             if name.lower() == 'content-type':
162                 name = 'CONTENT_TYPE'
163             else:
164                 name = 'HTTP_'+name.upper().replace('-', '_')
165             environ[name] = value
166 
167         request = Request.blank(path, environ=environ)
168         response = request.get_response(app)
169         if self.options.display_headers:
170             self.out(response.status)
171             for name, value in response.headerlist:
172                 self.out('%s: %s' % (name, value))
173         if response.charset:
174             self.out(response.ubody)
175         else:
176             self.out(response.body)
177         return 0
178 
179 if __name__ == '__main__': # pragma: no cover
180     sys.exit(main() or 0)
181
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py
--- a/pyramid/scripts/prequest.py
+++ b/pyramid/scripts/prequest.py
@@ -5,7 +5,7 @@
 
 from pyramid.compat import url_unquote
 from pyramid.request import Request
-from pyramid.paster import get_app
+from pyramid.paster import get_app, setup_logging
 from pyramid.scripts.common import parse_vars
 
 def main(argv=sys.argv, quiet=False):
@@ -97,12 +97,18 @@
         if not self.quiet:
             print(msg)
 
+    def configure_logging(self, app_spec):
+        setup_logging(app_spec)
+
     def run(self):
         if not len(self.args) >= 2:
             self.out('You must provide at least two arguments')
             return 2
         app_spec = self.args[0]
         path = self.args[1]
+
+        self.configure_logging(app_spec)
+
         if not path.startswith('/'):
             path = '/' + path

{"golden_diff": "diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py\n--- a/pyramid/scripts/prequest.py\n+++ b/pyramid/scripts/prequest.py\n@@ -5,7 +5,7 @@\n \n from pyramid.compat import url_unquote\n from pyramid.request import Request\n-from pyramid.paster import get_app\n+from pyramid.paster import get_app, setup_logging\n from pyramid.scripts.common import parse_vars\n \n def main(argv=sys.argv, quiet=False):\n@@ -97,12 +97,18 @@\n         if not self.quiet:\n             print(msg)\n \n+    def configure_logging(self, app_spec):\n+        setup_logging(app_spec)\n+\n     def run(self):\n         if not len(self.args) >= 2:\n             self.out('You must provide at least two arguments')\n             return 2\n         app_spec = self.args[0]\n         path = self.args[1]\n+\n+        self.configure_logging(app_spec)\n+\n         if not path.startswith('/'):\n             path = '/' + path\n", "issue": "prequest doesn't setup logging\n\n", "before_files": [{"content": "import base64\nimport optparse\nimport sys\nimport textwrap\n\nfrom pyramid.compat import url_unquote\nfrom pyramid.request import Request\nfrom pyramid.paster import get_app\nfrom pyramid.scripts.common import parse_vars\n\ndef main(argv=sys.argv, quiet=False):\n    command = PRequestCommand(argv, quiet)\n    return command.run()\n\nclass PRequestCommand(object):\n    description = \"\"\"\\\n    Run a request for the described application.\n\n    This command makes an artifical request to a web application that uses a\n    PasteDeploy (.ini) configuration file for the server and application.\n\n    Use \"prequest config.ini /path\" to request \"/path\".\n\n    Use \"prequest --method=POST config.ini /path < data\" to do a POST with\n    the given request body.\n\n    Use \"prequest --method=PUT config.ini /path < data\" to do a\n    PUT with the given request body.\n\n    Use \"prequest --method=PATCH config.ini /path < data\" to do a\n    PATCH with the given request body.\n\n    Use \"prequest --method=OPTIONS config.ini /path\" to do an\n    OPTIONS request.\n\n    Use \"prequest --method=PROPFIND config.ini /path\" to do a\n    PROPFIND request.\n\n    If the path is relative (doesn't begin with \"/\") it is interpreted as\n    relative to \"/\".  The path passed to this script should be URL-quoted.\n    The path can be succeeded with a query string (e.g. `/path?a=1&=b2').\n\n    The variable \"environ['paste.command_request']\" will be set to \"True\" in\n    the request's WSGI environment, so your application can distinguish these\n    calls from normal requests.\n    \"\"\"\n    usage = \"usage: %prog config_uri path_info [args/options]\"\n    parser = optparse.OptionParser(\n        usage=usage,\n        description=textwrap.dedent(description)\n        )\n    parser.add_option(\n        '-n', '--app-name',\n        dest='app_name',\n        metavar= 'NAME',\n        help=\"Load the named application from the config file (default 'main')\",\n        type=\"string\",\n        )\n    parser.add_option(\n        '--header',\n        dest='headers',\n        metavar='NAME:VALUE',\n        type='string',\n        action='append',\n        help=\"Header to add to request (you can use this option multiple times)\"\n        )\n    parser.add_option(\n        '-d', '--display-headers',\n        dest='display_headers',\n        action='store_true',\n        help='Display status and headers before the response body'\n        )\n    parser.add_option(\n        '-m', '--method',\n        dest='method',\n        choices=['GET', 'HEAD', 'POST', 'PUT', 'PATCH','DELETE',\n                 'PROPFIND', 'OPTIONS'],\n        type='choice',\n        help='Request method type (GET, POST, PUT, PATCH, DELETE, '\n             'PROPFIND, OPTIONS)',\n        )\n    parser.add_option(\n        '-l', '--login',\n        dest='login',\n        type='string',\n        help='HTTP basic auth username:password pair',\n        )\n\n    get_app = staticmethod(get_app)\n    stdin = sys.stdin\n\n    def __init__(self, argv, quiet=False):\n        self.quiet = quiet\n        self.options, self.args = self.parser.parse_args(argv[1:])\n\n    def out(self, msg): # pragma: no cover\n        if not self.quiet:\n            print(msg)\n\n    def run(self):\n        if not len(self.args) >= 2:\n            self.out('You must provide at least two arguments')\n            return 2\n        app_spec = self.args[0]\n        path = self.args[1]\n        if not path.startswith('/'):\n            path = '/' + path\n\n        try:\n            path, qs = path.split('?', 1)\n        except ValueError:\n            qs = ''\n\n        path = url_unquote(path)\n\n        headers = {}\n        if self.options.login:\n            enc = base64.b64encode(self.options.login.encode('ascii'))\n            headers['Authorization'] = 'Basic ' + enc.decode('ascii')\n\n        if self.options.headers:\n            for item in self.options.headers:\n                if ':' not in item:\n                    self.out(\n                        \"Bad --header=%s option, value must be in the form \"\n                        \"'name:value'\" % item)\n                    return 2\n                name, value = item.split(':', 1)\n                headers[name] = value.strip()\n\n        app = self.get_app(app_spec, self.options.app_name,\n                options=parse_vars(self.args[2:]))\n\n        request_method = (self.options.method or 'GET').upper()\n\n        environ = {\n            'REQUEST_METHOD': request_method,\n            'SCRIPT_NAME': '',           # may be empty if app is at the root\n            'PATH_INFO': path,\n            'SERVER_NAME': 'localhost',  # always mandatory\n            'SERVER_PORT': '80',         # always mandatory\n            'SERVER_PROTOCOL': 'HTTP/1.0',\n            'CONTENT_TYPE': 'text/plain',\n            'REMOTE_ADDR':'127.0.0.1',\n            'wsgi.run_once': True,\n            'wsgi.multithread': False,\n            'wsgi.multiprocess': False,\n            'wsgi.errors': sys.stderr,\n            'wsgi.url_scheme': 'http',\n            'wsgi.version': (1, 0),\n            'QUERY_STRING': qs,\n            'HTTP_ACCEPT': 'text/plain;q=1.0, */*;q=0.1',\n            'paste.command_request': True,\n            }\n\n        if request_method in ('POST', 'PUT', 'PATCH'):\n            environ['wsgi.input'] = self.stdin\n            environ['CONTENT_LENGTH'] = '-1'\n\n        for name, value in headers.items():\n            if name.lower() == 'content-type':\n                name = 'CONTENT_TYPE'\n            else:\n                name = 'HTTP_'+name.upper().replace('-', '_')\n            environ[name] = value\n\n        request = Request.blank(path, environ=environ)\n        response = request.get_response(app)\n        if self.options.display_headers:\n            self.out(response.status)\n            for name, value in response.headerlist:\n                self.out('%s: %s' % (name, value))\n        if response.charset:\n            self.out(response.ubody)\n        else:\n            self.out(response.body)\n        return 0\n\nif __name__ == '__main__': # pragma: no cover\n    sys.exit(main() or 0)\n", "path": "pyramid/scripts/prequest.py"}], "after_files": [{"content": "import base64\nimport optparse\nimport sys\nimport textwrap\n\nfrom pyramid.compat import url_unquote\nfrom pyramid.request import Request\nfrom pyramid.paster import get_app, setup_logging\nfrom pyramid.scripts.common import parse_vars\n\ndef main(argv=sys.argv, quiet=False):\n    command = PRequestCommand(argv, quiet)\n    return command.run()\n\nclass PRequestCommand(object):\n    description = \"\"\"\\\n    Run a request for the described application.\n\n    This command makes an artifical request to a web application that uses a\n    PasteDeploy (.ini) configuration file for the server and application.\n\n    Use \"prequest config.ini /path\" to request \"/path\".\n\n    Use \"prequest --method=POST config.ini /path < data\" to do a POST with\n    the given request body.\n\n    Use \"prequest --method=PUT config.ini /path < data\" to do a\n    PUT with the given request body.\n\n    Use \"prequest --method=PATCH config.ini /path < data\" to do a\n    PATCH with the given request body.\n\n    Use \"prequest --method=OPTIONS config.ini /path\" to do an\n    OPTIONS request.\n\n    Use \"prequest --method=PROPFIND config.ini /path\" to do a\n    PROPFIND request.\n\n    If the path is relative (doesn't begin with \"/\") it is interpreted as\n    relative to \"/\".  The path passed to this script should be URL-quoted.\n    The path can be succeeded with a query string (e.g. `/path?a=1&=b2').\n\n    The variable \"environ['paste.command_request']\" will be set to \"True\" in\n    the request's WSGI environment, so your application can distinguish these\n    calls from normal requests.\n    \"\"\"\n    usage = \"usage: %prog config_uri path_info [args/options]\"\n    parser = optparse.OptionParser(\n        usage=usage,\n        description=textwrap.dedent(description)\n        )\n    parser.add_option(\n        '-n', '--app-name',\n        dest='app_name',\n        metavar= 'NAME',\n        help=\"Load the named application from the config file (default 'main')\",\n        type=\"string\",\n        )\n    parser.add_option(\n        '--header',\n        dest='headers',\n        metavar='NAME:VALUE',\n        type='string',\n        action='append',\n        help=\"Header to add to request (you can use this option multiple times)\"\n        )\n    parser.add_option(\n        '-d', '--display-headers',\n        dest='display_headers',\n        action='store_true',\n        help='Display status and headers before the response body'\n        )\n    parser.add_option(\n        '-m', '--method',\n        dest='method',\n        choices=['GET', 'HEAD', 'POST', 'PUT', 'PATCH','DELETE',\n                 'PROPFIND', 'OPTIONS'],\n        type='choice',\n        help='Request method type (GET, POST, PUT, PATCH, DELETE, '\n             'PROPFIND, OPTIONS)',\n        )\n    parser.add_option(\n        '-l', '--login',\n        dest='login',\n        type='string',\n        help='HTTP basic auth username:password pair',\n        )\n\n    get_app = staticmethod(get_app)\n    stdin = sys.stdin\n\n    def __init__(self, argv, quiet=False):\n        self.quiet = quiet\n        self.options, self.args = self.parser.parse_args(argv[1:])\n\n    def out(self, msg): # pragma: no cover\n        if not self.quiet:\n            print(msg)\n\n    def configure_logging(self, app_spec):\n        setup_logging(app_spec)\n\n    def run(self):\n        if not len(self.args) >= 2:\n            self.out('You must provide at least two arguments')\n            return 2\n        app_spec = self.args[0]\n        path = self.args[1]\n\n        self.configure_logging(app_spec)\n\n        if not path.startswith('/'):\n            path = '/' + path\n\n        try:\n            path, qs = path.split('?', 1)\n        except ValueError:\n            qs = ''\n\n        path = url_unquote(path)\n\n        headers = {}\n        if self.options.login:\n            enc = base64.b64encode(self.options.login.encode('ascii'))\n            headers['Authorization'] = 'Basic ' + enc.decode('ascii')\n\n        if self.options.headers:\n            for item in self.options.headers:\n                if ':' not in item:\n                    self.out(\n                        \"Bad --header=%s option, value must be in the form \"\n                        \"'name:value'\" % item)\n                    return 2\n                name, value = item.split(':', 1)\n                headers[name] = value.strip()\n\n        app = self.get_app(app_spec, self.options.app_name,\n                options=parse_vars(self.args[2:]))\n\n        request_method = (self.options.method or 'GET').upper()\n\n        environ = {\n            'REQUEST_METHOD': request_method,\n            'SCRIPT_NAME': '',           # may be empty if app is at the root\n            'PATH_INFO': path,\n            'SERVER_NAME': 'localhost',  # always mandatory\n            'SERVER_PORT': '80',         # always mandatory\n            'SERVER_PROTOCOL': 'HTTP/1.0',\n            'CONTENT_TYPE': 'text/plain',\n            'REMOTE_ADDR':'127.0.0.1',\n            'wsgi.run_once': True,\n            'wsgi.multithread': False,\n            'wsgi.multiprocess': False,\n            'wsgi.errors': sys.stderr,\n            'wsgi.url_scheme': 'http',\n            'wsgi.version': (1, 0),\n            'QUERY_STRING': qs,\n            'HTTP_ACCEPT': 'text/plain;q=1.0, */*;q=0.1',\n            'paste.command_request': True,\n            }\n\n        if request_method in ('POST', 'PUT', 'PATCH'):\n            environ['wsgi.input'] = self.stdin\n            environ['CONTENT_LENGTH'] = '-1'\n\n        for name, value in headers.items():\n            if name.lower() == 'content-type':\n                name = 'CONTENT_TYPE'\n            else:\n                name = 'HTTP_'+name.upper().replace('-', '_')\n            environ[name] = value\n\n        request = Request.blank(path, environ=environ)\n        response = request.get_response(app)\n        if self.options.display_headers:\n            self.out(response.status)\n            for name, value in response.headerlist:\n                self.out('%s: %s' % (name, value))\n        if response.charset:\n            self.out(response.ubody)\n        else:\n            self.out(response.body)\n        return 0\n\nif __name__ == '__main__': # pragma: no cover\n    sys.exit(main() or 0)\n", "path": "pyramid/scripts/prequest.py"}]}