Repository: urllib3/urllib3

Issue:
2.0.0a2: Logging error with `StreamHandler` / `urllib3.add_stderr_logger`
### Subject

When using `urllib3.add_stderr_logger` (or using a StreamHandler), the formatting for the message to print out the request details fails.

This happens on the current main (2.0.0a2), release 2.0.0a2 and  2.0.0a1. 1.26.13 works fine.

### Environment

Describe your environment.
At least, paste here the output of:

```python
import platform
import urllib3

print("OS", platform.platform())
print("Python", platform.python_version())
print("urllib3", urllib3.__version__)
```

```
OS Linux-5.15.72-1-lts-x86_64-with-glibc2.35
Python 3.8.14
urllib3 2.0.0a2
```


### Steps to Reproduce

A simple and isolated way to reproduce the issue. A code snippet would be great.


```python
import urllib3

urllib3.add_stderr_logger()

pool = urllib3.PoolManager()

pool.request('GET', 'https://github.com/urllib3/urllib3')
```

### Expected Behavior

What should happen.

No logging error

### Actual Behavior

What happens instead.

```
(venv) [dev@dev-vm urllib3-test]$ python urllib3_test.py 
2022-11-30 15:34:40,252 DEBUG Added a stderr logging handler to logger: urllib3
2022-11-30 15:34:40,252 DEBUG Starting new HTTPS connection (1): github.com:443
--- Logging error ---
Traceback (most recent call last):
  File "/home/dev/.pyenv/versions/3.8.14/lib/python3.8/logging/__init__.py", line 1085, in emit
    msg = self.format(record)
  File "/home/dev/.pyenv/versions/3.8.14/lib/python3.8/logging/__init__.py", line 929, in format
    return fmt.format(record)
  File "/home/dev/.pyenv/versions/3.8.14/lib/python3.8/logging/__init__.py", line 668, in format
    record.message = record.getMessage()
  File "/home/dev/.pyenv/versions/3.8.14/lib/python3.8/logging/__init__.py", line 373, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "urllib3_test.py", line 7, in <module>
    pool.request('GET', 'https://github.com/urllib3/urllib3')
  File "/home/dev/urllib3-test/venv/lib/python3.8/site-packages/urllib3/_request_methods.py", line 110, in request
    return self.request_encode_url(
  File "/home/dev/urllib3-test/venv/lib/python3.8/site-packages/urllib3/_request_methods.py", line 143, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "/home/dev/urllib3-test/venv/lib/python3.8/site-packages/urllib3/poolmanager.py", line 433, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/home/dev/urllib3-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 791, in urlopen
    response = self._make_request(
  File "/home/dev/urllib3-test/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 547, in _make_request
    log.debug(
Message: '%s://%s:%s "%s %s %s" %s'
Arguments: ('https', 'github.com', 443, 'GET', '/urllib3/urllib3', 'HTTP/1.1', 200, None)
```



Discussion:

Resolving patch:
diff --git a/src/urllib3/connectionpool.py b/src/urllib3/connectionpool.py
--- a/src/urllib3/connectionpool.py
+++ b/src/urllib3/connectionpool.py
@@ -545,7 +545,7 @@ def _make_request(
         response._pool = self  # type: ignore[attr-defined]
 
         log.debug(
-            '%s://%s:%s "%s %s %s" %s',
+            '%s://%s:%s "%s %s %s" %s %s',
             self.scheme,
             self.host,
             self.port,


Test patch:
diff --git a/test/with_dummyserver/test_connectionpool.py b/test/with_dummyserver/test_connectionpool.py
--- a/test/with_dummyserver/test_connectionpool.py
+++ b/test/with_dummyserver/test_connectionpool.py
@@ -1,9 +1,7 @@
 from __future__ import annotations
 
 import io
-import logging
 import socket
-import sys
 import time
 import typing
 import warnings
@@ -39,10 +37,6 @@
 
 pytestmark = pytest.mark.flaky
 
-log = logging.getLogger("urllib3.connectionpool")
-log.setLevel(logging.NOTSET)
-log.addHandler(logging.StreamHandler(sys.stdout))
-
 
 def wait_for_socket(ready_event: Event) -> None:
     ready_event.wait()
diff --git a/test/with_dummyserver/test_https.py b/test/with_dummyserver/test_https.py
--- a/test/with_dummyserver/test_https.py
+++ b/test/with_dummyserver/test_https.py
@@ -1,7 +1,6 @@
 from __future__ import annotations
 
 import datetime
-import logging
 import os.path
 import shutil
 import ssl
@@ -52,11 +51,6 @@
 pytestmark = pytest.mark.flaky
 
 
-log = logging.getLogger("urllib3.connectionpool")
-log.setLevel(logging.NOTSET)
-log.addHandler(logging.StreamHandler(sys.stdout))
-
-
 TLSv1_CERTS = DEFAULT_CERTS.copy()
 TLSv1_CERTS["ssl_version"] = getattr(ssl, "PROTOCOL_TLSv1", None)