Skip to content

Google Cloud Logging

These functions are boilerplate to initialize Google Logging and ensure that messages are brief, descriptive & inexpensive.

from cloudy.google import logging

See Google's Cloud Logging Documentation.


get_gcloud_logger()

Get a logger for use with Google Cloud services like Cloud Run.

Source code in cloudy/google/logging.py
def get_gcloud_logger() -> logging.Logger:
    """Get a logger for use with Google Cloud services like Cloud Run."""
    _initialize_client()
    root_logger = logging.getLogger()

    # Turn off rasterio because it's commonly used in our packages and defaults to obnoxious levels of logs
    logging.getLogger("rasterio").setLevel(logging.WARNING)
    logging.getLogger("wandb").setLevel(logging.WARNING)

    return root_logger
Back to top