Simple, environment-based configuration
To enable logging for this library without any changes in your code, set the GOOGLE_SDK_PYTHON_LOGGING_SCOPE environment variable to a valid Google
logging scope. This configures handling of logging events (at level logging.DEBUG or higher) from this library in a default manner, emitting the logged
messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging
event.
A logging scope is a period-separated namespace that begins with google, identifying the Python module or package to log.
Valid logging scopes: google, google.cloud.asset.v1, google.api, google.auth, etc.
Invalid logging scopes: foo, 123, etc.
NOTE: If the logging scope is invalid, the library does not set up any logging handlers.
Environment-Based Examples
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1
Advanced, code-based configuration
You can also configure a valid logging scope using Python’s standard logging mechanism.
Code-Based Examples
import logging
from google.cloud import library_v1
base_logger = logging.getLogger("google")
base_logger.addHandler(logging.StreamHandler())
base_logger.setLevel(logging.DEBUG)
import logging
from google.cloud import library_v1
base_logger = logging.getLogger("google.cloud.library_v1")
base_logger.addHandler(logging.StreamHandler())
base_logger.setLevel(logging.DEBUG)