Repository: googleapis/google-api-python-client

Issue:
Incorrect logging level for `oauth2client.contrib.locked_file` (ref #427)
This is - as per request in the original #427 - a follow-up issue.

The function documentation says:

> Detects an appropriate cache module and returns it. Returns `googleapiclient.discovery_cache.base.Cache`, a cache object which is auto detected, or `None` if no cache object is available.

Exceptions in this context only provide a pythonic way to do control flow, and do not indicate anomalies or malfunctioning of the code.  `None` is a perfectly fine, as-per-specifications behaviour.  The correct level should probably be `INFO`.

Also, even if you would stand by the `WARNING` level, you should tidy up the messy log message.  This is what the user is met with:

```WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect
    from google.appengine.api import memcache
ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 42, in autodetect
    from . import file_cache
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 40, in <module>
    raise ImportError(
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
```

A saner way to to communicate with the user could potentially be:

`WARNING - No caching available (file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth)`



Discussion:
Simply removing `exc_info=True` from [this line](https://github.com/googleapis/google-api-python-client/blob/66bb32cc70353296dbf1876ae8c22baf6562cfb9/googleapiclient/discovery_cache/__init__.py#L46) would suffice (I made a fork just to do this).
Same/similar issue here.

Getting the following when instantiating a Google Drive client:

```
WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 44, in autodetect
    from . import file_cache
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 40, in <module>
    raise ImportError(
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 44, in autodetect
    from . import file_cache
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 40, in <module>
    raise ImportError(
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
```

This is causing issues in our monitoring stack because we consider logs with 'Traceback' in them to be unhandled exceptions and this warning message results in false positives.

So far my solution has been to lock `oauth2client` under 1.5.2, which is what I get when specifying < 4.0.0 in my `requirements.txt`.
Any idea when this might be merged?

The log output takes up way too much space and occurs way too frequently (every search causes it to be repeated), which just makes logs a chore to go through. I can understand showing all of this in the first search but repeating it every time is just annoying.
I've used the method proposed by @davidcpell to lower the oauth2client to 1.5.2, which works well. However, an exception is generated if I have logging turned on in our code when using the latest version of the oauth2client.
Any idea when this is likely to fixed?
This fixed my issue https://stackoverflow.com/questions/40154672/importerror-file-cache-is-unavailable-when-using-python-client-for-google-ser
@mysticaltech Thank you. That worked well!
Linking #1061 as it is related.

Resolving patch:
diff --git a/googleapiclient/discovery_cache/__init__.py b/googleapiclient/discovery_cache/__init__.py
--- a/googleapiclient/discovery_cache/__init__.py
+++ b/googleapiclient/discovery_cache/__init__.py
@@ -44,6 +44,7 @@ def autodetect():
         from . import file_cache
 
         return file_cache.cache
-    except Exception as e:
-        LOGGER.warning(e, exc_info=True)
+    except Exception:
+        LOGGER.info("file_cache is only supported with oauth2client<4.0.0",
+            exc_info=False)
         return None


Test patch: