Repository: googleapis/python-storage

Issue:
logging.info() triggers basicConfig()
When I use `download_as_string()` method or similar, `logging.root` logger is being activated by calling `logging.info()` on line 
https://github.com/googleapis/python-storage/blob/63ff23387f5873c609490be8e58d69ba34a10a5e/google/cloud/storage/blob.py#L926. It causes other loggers to be logged by the root logger which is unexpected as some apps require a single logger in strict format.

#### Environment details

  - OS type and version: ubuntu 20.04
  - Python version: `3.8.6`
  - pip version: `20.2.4`
  - `google-cloud-storage` version: `1.33.0`

#### Steps to reproduce

  1. set up your own logger for any logger
  2. call `logger.info("test")` (nothing should happen)
  3. run Client.from_service_account_json().get_bucket(...).blob(..., chunk_size=1024*1024).download_as_string()
  4. call `logger.info("test")` one more time
  5. log in basic format should appear on stdout (unexpected)

### How to fix it ###
you need to use your own logger (e.g. using `logging.getLogger(__name__)` instead of root logger.

Discussion:
andrewsg: Thanks!

Patch:
diff --git a/google/cloud/storage/blob.py b/google/cloud/storage/blob.py
index 4c868b4..ef7b88b 100644
--- a/google/cloud/storage/blob.py
+++ b/google/cloud/storage/blob.py
@@ -122,6 +122,8 @@ _CHUNKED_DOWNLOAD_CHECKSUM_MESSAGE = (
 _DEFAULT_CHUNKSIZE = 104857600  # 1024 * 1024 B * 100 = 100 MB
 _MAX_MULTIPART_SIZE = 8388608  # 8 MB
 
+_logger = logging.getLogger(__name__)
+
 
 class Blob(_PropertyMixin):
     """A wrapper around Cloud Storage's concept of an ``Object``.
@@ -923,7 +925,7 @@ class Blob(_PropertyMixin):
 
             if checksum:
                 msg = _CHUNKED_DOWNLOAD_CHECKSUM_MESSAGE.format(checksum)
-                logging.info(msg)
+                _logger.info(msg)
 
             if raw_download:
                 klass = RawChunkedDownload


Test patch:
diff --git a/tests/unit/test_blob.py b/tests/unit/test_blob.py
index dd7f13a..fc6eda6 100644
--- a/tests/unit/test_blob.py
+++ b/tests/unit/test_blob.py
@@ -1115,7 +1115,7 @@ class Test_Blob(unittest.TestCase):
     def test__do_download_w_chunks_w_checksum(self):
         from google.cloud.storage import blob as blob_module
 
-        with mock.patch("logging.info") as patch:
+        with mock.patch.object(blob_module._logger, "info") as patch:
             self._do_download_helper_w_chunks(
                 w_range=False, raw_download=False, checksum="md5"
             )
@@ -1124,7 +1124,9 @@ class Test_Blob(unittest.TestCase):
         )
 
     def test__do_download_w_chunks_wo_checksum(self):
-        with mock.patch("logging.info") as patch:
+        from google.cloud.storage import blob as blob_module
+
+        with mock.patch.object(blob_module._logger, "info") as patch:
             self._do_download_helper_w_chunks(
                 w_range=False, raw_download=False, checksum=None
             )