diff --git a/examples/account_management/create_customer.py b/examples/account_management/create_customer.py index cfe48811c..2eadae4e6 100755 --- a/examples/account_management/create_customer.py +++ b/examples/account_management/create_customer.py @@ -21,8 +21,9 @@ """ import argparse -import sys from datetime import datetime +import logging +import sys from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -34,6 +35,9 @@ CreateCustomerClientResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START create_customer] def main(client: GoogleAdsClient, manager_customer_id: str) -> None: diff --git a/examples/account_management/get_account_hierarchy.py b/examples/account_management/get_account_hierarchy.py index ef81d3c60..4a5db2fc5 100755 --- a/examples/account_management/get_account_hierarchy.py +++ b/examples/account_management/get_account_hierarchy.py @@ -23,6 +23,7 @@ """ import argparse +import logging import sys from typing import Optional, List, Dict @@ -42,6 +43,10 @@ GoogleAdsRow, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # ListAccessibleCustomersResponse is not directly used for a variable type, # but its attribute .resource_names is used, which is List[str]. diff --git a/examples/account_management/get_change_details.py b/examples/account_management/get_change_details.py index 7ec79ff73..382202434 100755 --- a/examples/account_management/get_change_details.py +++ b/examples/account_management/get_change_details.py @@ -20,6 +20,7 @@ import argparse from datetime import datetime, timedelta +import logging import sys from typing import Any @@ -38,6 +39,9 @@ ) from google.ads.googleads.v24.resources.types.change_event import ChangeEvent +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START get_change_details] def main(client: GoogleAdsClient, customer_id: str) -> None: diff --git a/examples/account_management/get_change_summary.py b/examples/account_management/get_change_summary.py index 44d549c60..d245ae4a4 100755 --- a/examples/account_management/get_change_summary.py +++ b/examples/account_management/get_change_summary.py @@ -17,6 +17,7 @@ """This example gets a list of which resources have been changed in an account.""" import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -31,6 +32,9 @@ ) from google.ads.googleads.v24.resources.types.change_status import ChangeStatus +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START get_change_summary] def main(client: GoogleAdsClient, customer_id: str) -> None: diff --git a/examples/account_management/invite_user_with_access_role.py b/examples/account_management/invite_user_with_access_role.py index f649a40d8..60aaf54c8 100755 --- a/examples/account_management/invite_user_with_access_role.py +++ b/examples/account_management/invite_user_with_access_role.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -33,6 +34,10 @@ CustomerUserAccessInvitation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # AccessRoleEnum is part of google.ads.googleads.v24.enums.types.access_role # but it's accessed via client.enums.AccessRoleEnum, so direct import for type hint might not be strictly needed for the parameter. # The field invitation.access_role expects an int (the enum value). diff --git a/examples/account_management/link_manager_to_client.py b/examples/account_management/link_manager_to_client.py index 5db5bbbf8..ea479dfd0 100755 --- a/examples/account_management/link_manager_to_client.py +++ b/examples/account_management/link_manager_to_client.py @@ -15,6 +15,7 @@ """This example shows how to link a manager customer to a client customer.""" import argparse +import logging import sys from google.api_core import protobuf_helpers @@ -50,6 +51,10 @@ CustomerManagerLink, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # ManagerLinkStatusEnum is used via client.enums diff --git a/examples/account_management/list_accessible_customers.py b/examples/account_management/list_accessible_customers.py index 2d156ff2c..b8d47bff4 100755 --- a/examples/account_management/list_accessible_customers.py +++ b/examples/account_management/list_accessible_customers.py @@ -20,6 +20,7 @@ documentation: https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid """ +import logging import sys from typing import List @@ -32,6 +33,9 @@ ListAccessibleCustomersResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START list_accessible_customers] def main(client: GoogleAdsClient) -> None: diff --git a/examples/account_management/update_user_access.py b/examples/account_management/update_user_access.py index 9b20cb81a..53035371c 100755 --- a/examples/account_management/update_user_access.py +++ b/examples/account_management/update_user_access.py @@ -22,32 +22,13 @@ """ import argparse +import logging import sys +from typing import Optional -from google.ads.googleads.client import GoogleAdsClient -from google.ads.googleads.errors import GoogleAdsException -from google.ads.googleads.v24.services.services.google_ads_service.client import ( - GoogleAdsServiceClient, -) -from google.ads.googleads.v24.services.types.google_ads_service import ( - SearchGoogleAdsRequest, - SearchPagedResponse, -) -from google.ads.googleads.v24.resources.types.customer_user_access import ( - CustomerUserAccess, -) -from google.ads.googleads.v24.services.services.customer_user_access_service.client import ( - CustomerUserAccessServiceClient, -) -from google.ads.googleads.v24.services.types.customer_user_access_service import ( - CustomerUserAccessOperation, - MutateCustomerUserAccessResponse, -) - -from google.api_core import protobuf_helpers -from google.protobuf.field_mask_pb2 import FieldMask +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) -from typing import Optional _ACCESS_ROLES = ["ADMIN", "STANDARD", "READ_ONLY", "EMAIL_ONLY"] diff --git a/examples/account_management/verify_advertiser_identity.py b/examples/account_management/verify_advertiser_identity.py index fb0995160..c04c05507 100755 --- a/examples/account_management/verify_advertiser_identity.py +++ b/examples/account_management/verify_advertiser_identity.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import Optional @@ -35,6 +36,9 @@ IdentityVerificationProgress, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/advanced_operations/add_ad_customizer.py b/examples/advanced_operations/add_ad_customizer.py index 0b072ba7a..6a6b91983 100755 --- a/examples/advanced_operations/add_ad_customizer.py +++ b/examples/advanced_operations/add_ad_customizer.py @@ -19,6 +19,7 @@ """ import argparse +import logging import sys from uuid import uuid4 @@ -51,6 +52,9 @@ MutateCustomizerAttributesResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/advanced_operations/add_ad_group_bid_modifier.py b/examples/advanced_operations/add_ad_group_bid_modifier.py index 9623bada9..0bdd7c619 100755 --- a/examples/advanced_operations/add_ad_group_bid_modifier.py +++ b/examples/advanced_operations/add_ad_group_bid_modifier.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -37,6 +38,9 @@ MutateAdGroupBidModifiersResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START add_ad_group_bid_modifier] def main( diff --git a/examples/advanced_operations/add_app_campaign.py b/examples/advanced_operations/add_app_campaign.py index 5e3c00f00..82495f9cb 100755 --- a/examples/advanced_operations/add_app_campaign.py +++ b/examples/advanced_operations/add_app_campaign.py @@ -23,6 +23,7 @@ import argparse from datetime import datetime, timedelta +import logging import sys from typing import List from uuid import uuid4 @@ -60,6 +61,9 @@ ) from google.ads.googleads.v24.services.types import * +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """Main function for running this example.""" diff --git a/examples/advanced_operations/add_bidding_data_exclusion.py b/examples/advanced_operations/add_bidding_data_exclusion.py index 7acd66210..43b285b72 100755 --- a/examples/advanced_operations/add_bidding_data_exclusion.py +++ b/examples/advanced_operations/add_bidding_data_exclusion.py @@ -22,6 +22,7 @@ """ import argparse +import logging import sys from uuid import uuid4 @@ -38,6 +39,9 @@ MutateBiddingDataExclusionsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/advanced_operations/add_bidding_seasonality_adjustment.py b/examples/advanced_operations/add_bidding_seasonality_adjustment.py index 15f82fadb..776d45ba1 100755 --- a/examples/advanced_operations/add_bidding_seasonality_adjustment.py +++ b/examples/advanced_operations/add_bidding_seasonality_adjustment.py @@ -22,6 +22,7 @@ """ import argparse +import logging import sys from uuid import uuid4 @@ -38,6 +39,9 @@ MutateBiddingSeasonalityAdjustmentsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/advanced_operations/add_demand_gen_campaign.py b/examples/advanced_operations/add_demand_gen_campaign.py index 3ea5e9049..937b10e89 100644 --- a/examples/advanced_operations/add_demand_gen_campaign.py +++ b/examples/advanced_operations/add_demand_gen_campaign.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import List from uuid import uuid4 @@ -51,6 +52,10 @@ MutateOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Temporary IDs for resources. BUDGET_TEMPORARY_ID: int = -1 CAMPAIGN_TEMPORARY_ID: int = -2 diff --git a/examples/advanced_operations/add_display_upload_ad.py b/examples/advanced_operations/add_display_upload_ad.py index 2c1f0ded6..54aeb20b2 100644 --- a/examples/advanced_operations/add_display_upload_ad.py +++ b/examples/advanced_operations/add_display_upload_ad.py @@ -18,9 +18,9 @@ """ import argparse -import sys - +import logging import requests +import sys from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -42,6 +42,10 @@ MutateAssetsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + BUNDLE_URL: str = "https://gaagl.page.link/ib87" diff --git a/examples/advanced_operations/add_dynamic_page_feed_asset.py b/examples/advanced_operations/add_dynamic_page_feed_asset.py index 53ed8798f..aedfb5ef7 100755 --- a/examples/advanced_operations/add_dynamic_page_feed_asset.py +++ b/examples/advanced_operations/add_dynamic_page_feed_asset.py @@ -15,6 +15,7 @@ """Adds a page feed with URLs for a Dynamic Search Ads campaign.""" import argparse +import logging import sys from typing import List, Optional @@ -75,6 +76,10 @@ MutateCampaignAssetSetsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # The label for the DSA page URLs. DSA_PAGE_URL_LABEL = "discounts" diff --git a/examples/advanced_operations/add_dynamic_search_ads.py b/examples/advanced_operations/add_dynamic_search_ads.py index 9a4879b80..167edd440 100755 --- a/examples/advanced_operations/add_dynamic_search_ads.py +++ b/examples/advanced_operations/add_dynamic_search_ads.py @@ -19,6 +19,7 @@ import argparse from datetime import datetime, timedelta +import logging import sys from uuid import uuid4 @@ -70,6 +71,9 @@ MutateCampaignsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/advanced_operations/add_performance_max_campaign.py b/examples/advanced_operations/add_performance_max_campaign.py index 3b8dd5fd7..5ef18e155 100644 --- a/examples/advanced_operations/add_performance_max_campaign.py +++ b/examples/advanced_operations/add_performance_max_campaign.py @@ -29,6 +29,7 @@ import argparse from datetime import datetime, timedelta +import logging import sys from typing import List, Optional, Iterable from uuid import uuid4 @@ -82,6 +83,10 @@ MutateOperationResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # We specify temporary IDs that are specific to a single mutate request. # Temporary IDs are always negative and unique within one mutate request. # diff --git a/examples/advanced_operations/add_responsive_search_ad_full.py b/examples/advanced_operations/add_responsive_search_ad_full.py index b670a49ab..111bf6456 100644 --- a/examples/advanced_operations/add_responsive_search_ad_full.py +++ b/examples/advanced_operations/add_responsive_search_ad_full.py @@ -23,9 +23,10 @@ """ import argparse +import logging import sys -import uuid from typing import List, Optional +import uuid from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -115,6 +116,10 @@ MutateCustomizerAttributesResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Keywords from user. KEYWORD_TEXT_EXACT = "example of exact match" KEYWORD_TEXT_PHRASE = "example of phrase match" diff --git a/examples/advanced_operations/add_smart_campaign.py b/examples/advanced_operations/add_smart_campaign.py index 605238b2d..51527ee32 100755 --- a/examples/advanced_operations/add_smart_campaign.py +++ b/examples/advanced_operations/add_smart_campaign.py @@ -19,6 +19,7 @@ """ import argparse +import logging import sys from typing import List, Optional from uuid import uuid4 @@ -102,6 +103,10 @@ ) from google.api_core import protobuf_helpers +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Geo target constant for New York City. _GEO_TARGET_CONSTANT = "1023191" # Country code is a two-letter ISO-3166 code, for a list of all codes see: diff --git a/examples/advanced_operations/create_and_attach_shared_keyword_set.py b/examples/advanced_operations/create_and_attach_shared_keyword_set.py index 4306c345e..f29c3cb4f 100755 --- a/examples/advanced_operations/create_and_attach_shared_keyword_set.py +++ b/examples/advanced_operations/create_and_attach_shared_keyword_set.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import List import uuid @@ -58,6 +59,9 @@ SharedSetOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: campaign_service: CampaignServiceClient = client.get_service( diff --git a/examples/advanced_operations/find_and_remove_criteria_from_shared_set.py b/examples/advanced_operations/find_and_remove_criteria_from_shared_set.py index 76560fbd5..6e6ee5746 100755 --- a/examples/advanced_operations/find_and_remove_criteria_from_shared_set.py +++ b/examples/advanced_operations/find_and_remove_criteria_from_shared_set.py @@ -15,6 +15,7 @@ """Demonstrates how to find and remove shared sets, and shared set criteria.""" import argparse +import logging import sys from typing import List @@ -46,6 +47,9 @@ SharedCriterionOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: ga_service: GoogleAdsServiceClient = client.get_service("GoogleAdsService") diff --git a/examples/advanced_operations/get_ad_group_bid_modifiers.py b/examples/advanced_operations/get_ad_group_bid_modifiers.py index 942b6bcb0..f2ad85946 100755 --- a/examples/advanced_operations/get_ad_group_bid_modifiers.py +++ b/examples/advanced_operations/get_ad_group_bid_modifiers.py @@ -15,6 +15,7 @@ """This example illustrates how to retrieve ad group bid modifiers.""" import argparse +import logging import sys from typing import Optional @@ -32,6 +33,9 @@ SearchGoogleAdsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, customer_id: str, ad_group_id: Optional[str] = None diff --git a/examples/advanced_operations/upload_video.py b/examples/advanced_operations/upload_video.py index 86dbf017c..0ae8fa368 100644 --- a/examples/advanced_operations/upload_video.py +++ b/examples/advanced_operations/upload_video.py @@ -16,9 +16,9 @@ import argparse import itertools +import logging import os import sys -import logging from typing import Iterator, Iterable, List, MutableSequence import google.auth @@ -51,6 +51,9 @@ from google.protobuf import field_mask_pb2 from google.ads.googleads.v24.resources.types import youtube_video_upload +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, customer_id: str, video_file_path: str diff --git a/examples/advanced_operations/use_cross_account_bidding_strategy.py b/examples/advanced_operations/use_cross_account_bidding_strategy.py index 82508226b..d31ad4685 100755 --- a/examples/advanced_operations/use_cross_account_bidding_strategy.py +++ b/examples/advanced_operations/use_cross_account_bidding_strategy.py @@ -19,6 +19,7 @@ """ import argparse +import logging import sys from typing import Iterator from uuid import uuid4 @@ -57,6 +58,9 @@ SearchGoogleAdsStreamResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/advanced_operations/use_portfolio_bidding_strategy.py b/examples/advanced_operations/use_portfolio_bidding_strategy.py index 9132737cf..d8b245ff3 100755 --- a/examples/advanced_operations/use_portfolio_bidding_strategy.py +++ b/examples/advanced_operations/use_portfolio_bidding_strategy.py @@ -15,6 +15,7 @@ """This example constructs a campaign with a Portfolio Bidding Strategy.""" import argparse +import logging import sys import uuid @@ -50,6 +51,9 @@ MutateCampaignsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: campaign_budget_service: CampaignBudgetServiceClient = client.get_service( diff --git a/examples/assets/add_call.py b/examples/assets/add_call.py index 3bd3245be..826acc04e 100755 --- a/examples/assets/add_call.py +++ b/examples/assets/add_call.py @@ -15,8 +15,9 @@ """This example adds a call asset to a specific account.""" import argparse -from typing import Optional +import logging import sys +from typing import Optional from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -30,6 +31,10 @@ CustomerAsset, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Country code is a two-letter ISO-3166 code, for a list of all codes see: # https://developers.google.com/google-ads/api/reference/data/codes-formats#expandable-17 _DEFAULT_PHONE_COUNTRY: str = "US" diff --git a/examples/assets/add_hotel_callout.py b/examples/assets/add_hotel_callout.py index d4c08e26e..bdf214001 100755 --- a/examples/assets/add_hotel_callout.py +++ b/examples/assets/add_hotel_callout.py @@ -15,8 +15,9 @@ """This example adds a hotel callout extension asset to a specific account.""" import argparse -from typing import List +import logging import sys +from typing import List from google.ads.googleads.client import GoogleAdsClient @@ -30,6 +31,9 @@ CustomerAsset, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, language_code: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/assets/add_lead_form_asset.py b/examples/assets/add_lead_form_asset.py index 84e20ef9a..23fa0a945 100755 --- a/examples/assets/add_lead_form_asset.py +++ b/examples/assets/add_lead_form_asset.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from uuid import uuid4 @@ -37,6 +38,9 @@ CampaignAsset, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: """Creates a lead form and lead form extension for the given campaign. diff --git a/examples/assets/add_prices.py b/examples/assets/add_prices.py index 4b98563b1..366b038be 100644 --- a/examples/assets/add_prices.py +++ b/examples/assets/add_prices.py @@ -15,8 +15,9 @@ """This example adds a price asset and associates it with an account.""" import argparse -from typing import Optional +import logging import sys +from typing import Optional from uuid import uuid4 from google.ads.googleads.client import GoogleAdsClient @@ -35,6 +36,9 @@ CustomerAsset, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/assets/add_sitelinks.py b/examples/assets/add_sitelinks.py index 06abbee6e..17215f4a2 100755 --- a/examples/assets/add_sitelinks.py +++ b/examples/assets/add_sitelinks.py @@ -18,8 +18,9 @@ """ import argparse -from typing import List +import logging import sys +from typing import List from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -32,6 +33,9 @@ CampaignAsset, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: """Adds sitelinks to a campaign using assets. diff --git a/examples/assets/upload_image_asset.py b/examples/assets/upload_image_asset.py index fae530d0e..a9ccce4db 100644 --- a/examples/assets/upload_image_asset.py +++ b/examples/assets/upload_image_asset.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from examples.utils.example_helpers import get_image_bytes_from_url @@ -26,6 +27,9 @@ from google.ads.googleads.v24.services.types.asset_service import AssetOperation from google.ads.googleads.v24.resources.types.asset import Asset +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START upload_image_asset] def main(client: GoogleAdsClient, customer_id: str) -> None: diff --git a/examples/asyncio/async_add_campaigns.py b/examples/asyncio/async_add_campaigns.py index 7bfbdd5cf..e4af38044 100644 --- a/examples/asyncio/async_add_campaigns.py +++ b/examples/asyncio/async_add_campaigns.py @@ -15,8 +15,8 @@ """This example illustrates how to add a campaign using asyncio.""" import argparse -import asyncio import datetime +import logging import sys from typing import List import uuid @@ -38,6 +38,10 @@ MutateOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + _START_DATE_FORMAT: str = "%Y%m%d 00:00:00" _END_DATE_FORMAT: str = "%Y%m%d 23:59:59" diff --git a/examples/asyncio/async_search.py b/examples/asyncio/async_search.py index ce12f7242..9cabeabe7 100755 --- a/examples/asyncio/async_search.py +++ b/examples/asyncio/async_search.py @@ -15,7 +15,7 @@ """This example illustrates how to get all campaigns using asyncio.""" import argparse -import asyncio +import logging import sys from typing import List @@ -28,6 +28,9 @@ GoogleAdsRow, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + async def main(client: GoogleAdsClient, customer_id: str) -> None: ga_service: GoogleAdsServiceAsyncClient = client.get_service( diff --git a/examples/asyncio/async_search_stream.py b/examples/asyncio/async_search_stream.py index f47feea7a..6bd3689c0 100755 --- a/examples/asyncio/async_search_stream.py +++ b/examples/asyncio/async_search_stream.py @@ -15,7 +15,7 @@ """This example illustrates how to get all campaigns using asyncio.""" import argparse -import asyncio +import logging import sys from typing import List @@ -28,6 +28,9 @@ GoogleAdsRow, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + async def main(client: GoogleAdsClient, customer_id: str) -> None: ga_service: GoogleAdsServiceAsyncClient = client.get_service( diff --git a/examples/audience_insights/generate_audience_insights.py b/examples/audience_insights/generate_audience_insights.py index af4cb6f75..4a37df97e 100644 --- a/examples/audience_insights/generate_audience_insights.py +++ b/examples/audience_insights/generate_audience_insights.py @@ -15,6 +15,7 @@ """This example illustrates how to generate audience insights.""" import argparse +import logging import sys from typing import Any @@ -43,6 +44,9 @@ LocationInfo, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, custom_name: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/basic_operations/add_ad_groups.py b/examples/basic_operations/add_ad_groups.py index b37ca9f67..7e7ca1ada 100755 --- a/examples/basic_operations/add_ad_groups.py +++ b/examples/basic_operations/add_ad_groups.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import List import uuid @@ -36,6 +37,9 @@ ) from google.ads.googleads.v24.resources.types.ad_group import AdGroup +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: ad_group_service: AdGroupServiceClient = client.get_service( diff --git a/examples/basic_operations/add_campaigns.py b/examples/basic_operations/add_campaigns.py index 1b2f9f4b3..40967e570 100755 --- a/examples/basic_operations/add_campaigns.py +++ b/examples/basic_operations/add_campaigns.py @@ -19,6 +19,7 @@ import argparse import datetime +import logging import sys from typing import List import uuid @@ -44,6 +45,10 @@ ) from google.ads.googleads.v24.resources.types.campaign import Campaign +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + _START_DATE_FORMAT: str = "%Y%m%d 00:00:00" _END_DATE_FORMAT: str = "%Y%m%d 23:59:59" diff --git a/examples/basic_operations/get_campaigns.py b/examples/basic_operations/get_campaigns.py index 1174f0565..fcdce24a4 100755 --- a/examples/basic_operations/get_campaigns.py +++ b/examples/basic_operations/get_campaigns.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import Iterator, List @@ -31,6 +32,9 @@ GoogleAdsRow, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START get_campaigns] def main(client: GoogleAdsClient, customer_id: str) -> None: diff --git a/examples/basic_operations/get_responsive_search_ads.py b/examples/basic_operations/get_responsive_search_ads.py index 438285517..69854b1e8 100755 --- a/examples/basic_operations/get_responsive_search_ads.py +++ b/examples/basic_operations/get_responsive_search_ads.py @@ -19,6 +19,7 @@ """ import argparse +import logging import sys from typing import List, Optional, Sequence @@ -34,6 +35,9 @@ SearchGoogleAdsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/basic_operations/pause_ad.py b/examples/basic_operations/pause_ad.py index b504bb4e2..42b87f83a 100755 --- a/examples/basic_operations/pause_ad.py +++ b/examples/basic_operations/pause_ad.py @@ -15,6 +15,7 @@ """This example pauses an ad.""" import argparse +import logging import sys from typing import List @@ -31,6 +32,9 @@ MutateAdGroupAdsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/basic_operations/remove_campaign.py b/examples/basic_operations/remove_campaign.py index 13bfeebf5..fa0789904 100755 --- a/examples/basic_operations/remove_campaign.py +++ b/examples/basic_operations/remove_campaign.py @@ -15,6 +15,7 @@ """This example removes an existing campaign.""" import argparse +import logging import sys from typing import List @@ -28,6 +29,9 @@ MutateCampaignsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: campaign_service: CampaignServiceClient = client.get_service( diff --git a/examples/basic_operations/search_for_google_ads_fields.py b/examples/basic_operations/search_for_google_ads_fields.py index 747a28359..84dd209ee 100755 --- a/examples/basic_operations/search_for_google_ads_fields.py +++ b/examples/basic_operations/search_for_google_ads_fields.py @@ -21,6 +21,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -36,6 +37,9 @@ SearchGoogleAdsFieldsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, name_prefix: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/basic_operations/update_ad_group.py b/examples/basic_operations/update_ad_group.py index 9adf016d4..49ecc56ae 100755 --- a/examples/basic_operations/update_ad_group.py +++ b/examples/basic_operations/update_ad_group.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import List @@ -37,6 +38,9 @@ MutateAdGroupsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START update_ad_group] def main( diff --git a/examples/basic_operations/update_campaign.py b/examples/basic_operations/update_campaign.py index 29a50fc32..537365668 100755 --- a/examples/basic_operations/update_campaign.py +++ b/examples/basic_operations/update_campaign.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import List @@ -34,6 +35,9 @@ MutateCampaignsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: campaign_service: CampaignServiceClient = client.get_service( diff --git a/examples/basic_operations/update_responsive_search_ad.py b/examples/basic_operations/update_responsive_search_ad.py index f3fb9fb96..40d1eadd8 100755 --- a/examples/basic_operations/update_responsive_search_ad.py +++ b/examples/basic_operations/update_responsive_search_ad.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import List from uuid import uuid4 @@ -36,6 +37,9 @@ MutateAdsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START update_responsive_search_ad] def main(client: GoogleAdsClient, customer_id: str, ad_id: str) -> None: diff --git a/examples/billing/add_account_budget_proposal.py b/examples/billing/add_account_budget_proposal.py index b9218ebbd..0cf29afa8 100755 --- a/examples/billing/add_account_budget_proposal.py +++ b/examples/billing/add_account_budget_proposal.py @@ -18,12 +18,16 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START add_account_budget_proposal] def main(client: GoogleAdsClient, customer_id: str, billing_setup_id: str): diff --git a/examples/billing/add_billing_setup.py b/examples/billing/add_billing_setup.py index 042aeb9cf..05894c178 100755 --- a/examples/billing/add_billing_setup.py +++ b/examples/billing/add_billing_setup.py @@ -25,6 +25,7 @@ import argparse from datetime import datetime, timedelta +import logging import sys from typing import Any, Optional from uuid import uuid4 @@ -32,6 +33,9 @@ from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/billing/get_invoices.py b/examples/billing/get_invoices.py index 3e8f0c7c0..74e37d35f 100755 --- a/examples/billing/get_invoices.py +++ b/examples/billing/get_invoices.py @@ -16,12 +16,16 @@ import argparse from datetime import date, timedelta +import logging import sys from typing import Optional from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, billing_setup_id: str): """The main method that creates all necessary entities for the example. diff --git a/examples/campaign_management/add_campaign_labels.py b/examples/campaign_management/add_campaign_labels.py index 38f7f55cd..26fd8827b 100755 --- a/examples/campaign_management/add_campaign_labels.py +++ b/examples/campaign_management/add_campaign_labels.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import List, Any @@ -39,6 +40,9 @@ CampaignLabel, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START add_campaign_labels] def main( diff --git a/examples/campaign_management/add_complete_campaigns_using_batch_job.py b/examples/campaign_management/add_complete_campaigns_using_batch_job.py index 6cd015d1f..d428f6970 100755 --- a/examples/campaign_management/add_complete_campaigns_using_batch_job.py +++ b/examples/campaign_management/add_complete_campaigns_using_batch_job.py @@ -18,10 +18,10 @@ """ import argparse -import asyncio +import logging import sys -from uuid import uuid4 from typing import Any, List, Coroutine +from uuid import uuid4 from google.api_core.operation import Operation @@ -62,6 +62,10 @@ BatchJobOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + NUMBER_OF_CAMPAIGNS_TO_ADD: int = 2 NUMBER_OF_AD_GROUPS_TO_ADD: int = 2 NUMBER_OF_KEYWORDS_TO_ADD: int = 4 diff --git a/examples/campaign_management/get_all_disapproved_ads.py b/examples/campaign_management/get_all_disapproved_ads.py index f776d7c1f..69b53f512 100755 --- a/examples/campaign_management/get_all_disapproved_ads.py +++ b/examples/campaign_management/get_all_disapproved_ads.py @@ -15,6 +15,7 @@ """This illustrates how to retrieve disapproved ads in a given campaign.""" import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -32,6 +33,9 @@ PolicyApprovalStatusEnum, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: ga_service: GoogleAdsServiceClient = client.get_service("GoogleAdsService") diff --git a/examples/campaign_management/set_ad_parameters.py b/examples/campaign_management/set_ad_parameters.py index 5dcc39a65..1976751f0 100755 --- a/examples/campaign_management/set_ad_parameters.py +++ b/examples/campaign_management/set_ad_parameters.py @@ -15,6 +15,7 @@ """This example sets ad parameters for an ad group criterion.""" import argparse +import logging import sys from typing import List @@ -32,6 +33,9 @@ ) from google.ads.googleads.v24.resources.types.ad_parameter import AdParameter +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/campaign_management/update_campaign_criterion_bid_modifier.py b/examples/campaign_management/update_campaign_criterion_bid_modifier.py index 37af08c67..f22937f88 100755 --- a/examples/campaign_management/update_campaign_criterion_bid_modifier.py +++ b/examples/campaign_management/update_campaign_criterion_bid_modifier.py @@ -15,6 +15,7 @@ """Updates a campaign criterion with a new bid modifier.""" import argparse +import logging import sys from google.api_core import protobuf_helpers @@ -32,6 +33,9 @@ CampaignCriterion, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/campaign_management/validate_ad.py b/examples/campaign_management/validate_ad.py index 76061f61a..0ab61d681 100755 --- a/examples/campaign_management/validate_ad.py +++ b/examples/campaign_management/validate_ad.py @@ -20,6 +20,7 @@ """ import argparse +import logging import sys from typing import List @@ -42,6 +43,9 @@ ) from google.ads.googleads.v24.common.types.policy import PolicyTopicEntry +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str) -> None: ad_group_ad_operation: AdGroupAdOperation = client.get_type( diff --git a/examples/custom_logging_interceptor/cloud_logging_interceptor.py b/examples/custom_logging_interceptor/cloud_logging_interceptor.py index f808276d6..b9531ea76 100644 --- a/examples/custom_logging_interceptor/cloud_logging_interceptor.py +++ b/examples/custom_logging_interceptor/cloud_logging_interceptor.py @@ -19,6 +19,8 @@ within the class (in this case, a Cloud Logging client). """ +import logging +import sys import time from typing import Any, Callable, Dict, Optional @@ -27,6 +29,9 @@ from google.ads.googleads.interceptors import LoggingInterceptor +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + class CloudLoggingInterceptor(LoggingInterceptor): """An interceptor that logs rpc request and response details to Google Cloud Logging. diff --git a/examples/custom_logging_interceptor/get_campaigns.py b/examples/custom_logging_interceptor/get_campaigns.py index 704fd49d3..1eddb79b2 100755 --- a/examples/custom_logging_interceptor/get_campaigns.py +++ b/examples/custom_logging_interceptor/get_campaigns.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import Any, Iterable @@ -35,6 +36,9 @@ from cloud_logging_interceptor import CloudLoggingInterceptor +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: # Instantiate the GoogleAdsService object with a custom interceptor. diff --git a/examples/error_handling/handle_keyword_policy_violations.py b/examples/error_handling/handle_keyword_policy_violations.py index 16c0658e8..ef4a99c16 100755 --- a/examples/error_handling/handle_keyword_policy_violations.py +++ b/examples/error_handling/handle_keyword_policy_violations.py @@ -26,6 +26,7 @@ """ import argparse +import logging import sys from typing import Any, List, Optional, Tuple @@ -39,6 +40,9 @@ ) from google.ads.googleads.v24.common.types.policy import PolicyViolationKey +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/error_handling/handle_partial_failure.py b/examples/error_handling/handle_partial_failure.py index 02c7b540d..61d568142 100755 --- a/examples/error_handling/handle_partial_failure.py +++ b/examples/error_handling/handle_partial_failure.py @@ -15,9 +15,10 @@ """This shows how to handle responses that may include partial_failure errors.""" import argparse +import logging import sys -import uuid from typing import Any, List +import uuid from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -33,6 +34,9 @@ MutateAdGroupsRequest, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: """Runs the example code, which demonstrates how to handle partial failures. diff --git a/examples/error_handling/handle_rate_exceeded_error.py b/examples/error_handling/handle_rate_exceeded_error.py index b7dfebde8..8af4c298c 100755 --- a/examples/error_handling/handle_rate_exceeded_error.py +++ b/examples/error_handling/handle_rate_exceeded_error.py @@ -23,6 +23,8 @@ """ import argparse +import logging +import sys from time import sleep from typing import List, Any @@ -41,6 +43,10 @@ MutateAdGroupCriteriaResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Number of requests to be run. NUM_REQUESTS: int = 5 # Number of keywords to be validated in each API call. diff --git a/examples/error_handling/handle_responsive_search_ad_policy_violations.py b/examples/error_handling/handle_responsive_search_ad_policy_violations.py index e9c2bd83f..714c15c84 100755 --- a/examples/error_handling/handle_responsive_search_ad_policy_violations.py +++ b/examples/error_handling/handle_responsive_search_ad_policy_violations.py @@ -19,9 +19,10 @@ """ import argparse +import logging import sys -import uuid from typing import List +import uuid from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -46,6 +47,9 @@ PolicyFindingErrorEnum, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str) -> None: """Handles responsive search ad policy violations. diff --git a/examples/experiments/create_asset_optimization_experiment.py b/examples/experiments/create_asset_optimization_experiment.py index e94d872bc..5be559970 100644 --- a/examples/experiments/create_asset_optimization_experiment.py +++ b/examples/experiments/create_asset_optimization_experiment.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import List, Tuple, Any from uuid import uuid4 @@ -29,6 +30,9 @@ MutateOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, customer_id: str, asset_group_id: str diff --git a/examples/experiments/create_search_adopt_ai_max_experiment.py b/examples/experiments/create_search_adopt_ai_max_experiment.py index ef1aee19d..f488bf1f8 100644 --- a/examples/experiments/create_search_adopt_ai_max_experiment.py +++ b/examples/experiments/create_search_adopt_ai_max_experiment.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from uuid import uuid4 @@ -26,6 +27,9 @@ from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: """Creates an ADOPT_AI_MAX intra-campaign experiment for a Search campaign. diff --git a/examples/experiments/create_search_custom_experiment.py b/examples/experiments/create_search_custom_experiment.py index eaec7e9b5..ba20981c7 100644 --- a/examples/experiments/create_search_custom_experiment.py +++ b/examples/experiments/create_search_custom_experiment.py @@ -25,9 +25,10 @@ """ import argparse +import logging import sys -import uuid from typing import List, Any +import uuid from google.api_core import protobuf_helpers @@ -60,6 +61,9 @@ ) from google.ads.googleads.v24.resources.types.campaign import Campaign +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, customer_id: str, base_campaign_id: str diff --git a/examples/experiments/get_experiment_performance.py b/examples/experiments/get_experiment_performance.py index 08e9cdefc..a621a3f4c 100644 --- a/examples/experiments/get_experiment_performance.py +++ b/examples/experiments/get_experiment_performance.py @@ -19,9 +19,10 @@ """ import argparse +import logging import sys -import uuid from typing import Iterator, List +import uuid from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -42,6 +43,10 @@ CampaignBudgetMapping, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Constants for decision making # Choose a confidence level based on your specific needs. # - The p-value (probability value) is the probability that the observed performance diff --git a/examples/google-ads-account-analyzer-demo/analyzer.py b/examples/google-ads-account-analyzer-demo/analyzer.py index 432f92c6d..0db04c94b 100644 --- a/examples/google-ads-account-analyzer-demo/analyzer.py +++ b/examples/google-ads-account-analyzer-demo/analyzer.py @@ -16,12 +16,17 @@ import argparse +import logging import sys from typing import Optional, Dict, List, Any from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + _DEFAULT_LOG_SPACE_LENGTH = 4 diff --git a/examples/incentives/apply_incentive.py b/examples/incentives/apply_incentive.py index f57534097..abbea78a8 100644 --- a/examples/incentives/apply_incentive.py +++ b/examples/incentives/apply_incentive.py @@ -21,6 +21,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -33,6 +34,9 @@ IncentiveServiceClient, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/incentives/fetch_incentives.py b/examples/incentives/fetch_incentives.py index 3fc40b7ba..f41b93d07 100644 --- a/examples/incentives/fetch_incentives.py +++ b/examples/incentives/fetch_incentives.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -30,6 +31,9 @@ IncentiveServiceClient, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/misc/add_ad_group_image_asset.py b/examples/misc/add_ad_group_image_asset.py index 745cdea46..2da1cea11 100644 --- a/examples/misc/add_ad_group_image_asset.py +++ b/examples/misc/add_ad_group_image_asset.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -32,6 +33,9 @@ MutateAdGroupAssetsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/misc/campaign_report_to_csv.py b/examples/misc/campaign_report_to_csv.py index 33f482efa..ae9992453 100755 --- a/examples/misc/campaign_report_to_csv.py +++ b/examples/misc/campaign_report_to_csv.py @@ -28,8 +28,7 @@ """ import argparse -import csv -from collections.abc import Iterator +import logging import os import sys @@ -44,6 +43,10 @@ SearchGoogleAdsStreamResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + _DEFAULT_FILE_NAME = "campaign_report_to_csv_results.csv" _QUERY: str = """ SELECT diff --git a/examples/misc/set_custom_client_timeouts.py b/examples/misc/set_custom_client_timeouts.py index 73d3f5f04..0385d8938 100755 --- a/examples/misc/set_custom_client_timeouts.py +++ b/examples/misc/set_custom_client_timeouts.py @@ -23,7 +23,7 @@ """ import argparse -from collections.abc import Iterator +import logging import sys from typing import List @@ -41,6 +41,10 @@ from google.api_core.exceptions import DeadlineExceeded from google.api_core.retry import Retry +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + _CLIENT_TIMEOUT_SECONDS = 5 * 60 # 5 minutes. _QUERY: str = "SELECT campaign.id FROM campaign" diff --git a/examples/misc/upload_image_asset.py b/examples/misc/upload_image_asset.py index 0fbf2974a..72097f8af 100644 --- a/examples/misc/upload_image_asset.py +++ b/examples/misc/upload_image_asset.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from examples.utils.example_helpers import get_image_bytes_from_url @@ -33,6 +34,9 @@ MutateAssetsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START upload_image_asset] def main(client: GoogleAdsClient, customer_id: str) -> None: diff --git a/examples/planning/forecast_reach.py b/examples/planning/forecast_reach.py index 88b6140a0..bc7e72489 100755 --- a/examples/planning/forecast_reach.py +++ b/examples/planning/forecast_reach.py @@ -15,6 +15,7 @@ """This code example generates a video ads reach forecast.""" import argparse +import logging import math import sys @@ -44,6 +45,10 @@ PlannedProduct, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + ONE_MILLION = 1.0e6 diff --git a/examples/planning/generate_forecast_metrics.py b/examples/planning/generate_forecast_metrics.py index 6ad0f3a30..db9ece366 100755 --- a/examples/planning/generate_forecast_metrics.py +++ b/examples/planning/generate_forecast_metrics.py @@ -20,6 +20,7 @@ import argparse from datetime import datetime, timedelta +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -40,6 +41,9 @@ GenerateKeywordForecastMetricsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START generate_forecast_metrics] def main(client: GoogleAdsClient, customer_id: str): diff --git a/examples/planning/generate_historical_metrics.py b/examples/planning/generate_historical_metrics.py index 9e1daa3bb..0b00baafe 100755 --- a/examples/planning/generate_historical_metrics.py +++ b/examples/planning/generate_historical_metrics.py @@ -18,9 +18,10 @@ https://developers.google.com/google-ads/api/docs/keyword-planning/generate-historical-metrics """ -from typing import Iterable import argparse +import logging import sys +from typing import Iterable from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -40,6 +41,9 @@ GenerateKeywordHistoricalMetricsResult, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START generate_historical_metrics] def main(client: GoogleAdsClient, customer_id: str): diff --git a/examples/planning/generate_keyword_ideas.py b/examples/planning/generate_keyword_ideas.py index 8d70e59a8..91f2df784 100755 --- a/examples/planning/generate_keyword_ideas.py +++ b/examples/planning/generate_keyword_ideas.py @@ -15,6 +15,7 @@ """This example generates keyword ideas from a list of seed keywords.""" import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -38,6 +39,10 @@ GenerateKeywordIdeaResult, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Location IDs are listed here: # https://developers.google.com/google-ads/api/reference/data/geotargets # and they can also be retrieved using the GeoTargetConstantService as shown diff --git a/examples/planning/get_ad_group_criterion_cpc_bid_simulations.py b/examples/planning/get_ad_group_criterion_cpc_bid_simulations.py index 495dceda7..de12c8590 100755 --- a/examples/planning/get_ad_group_criterion_cpc_bid_simulations.py +++ b/examples/planning/get_ad_group_criterion_cpc_bid_simulations.py @@ -17,9 +17,10 @@ To get ad groups, run get_ad_groups.py. """ -from typing import Iterable import argparse +import logging import sys +from typing import Iterable from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -37,6 +38,9 @@ GoogleAdsRow, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START get_ad_group_criterion_cpc_bid_simulations] def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str): diff --git a/examples/recommendations/detect_and_apply_recommendations.py b/examples/recommendations/detect_and_apply_recommendations.py index 363fe85ba..63511cfa6 100755 --- a/examples/recommendations/detect_and_apply_recommendations.py +++ b/examples/recommendations/detect_and_apply_recommendations.py @@ -29,6 +29,7 @@ """ import argparse +import logging import sys from typing import List, Iterable @@ -42,6 +43,9 @@ ApplyRecommendationResult, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/recommendations/dismiss_recommendation.py b/examples/recommendations/dismiss_recommendation.py index 018f585fc..d8a9a29ee 100755 --- a/examples/recommendations/dismiss_recommendation.py +++ b/examples/recommendations/dismiss_recommendation.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -30,6 +31,9 @@ DismissRecommendationResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, customer_id: str, recommendation_id: str diff --git a/examples/recommendations/generate_budget_recommendations.py b/examples/recommendations/generate_budget_recommendations.py index abe2b7073..13fa8b1f6 100644 --- a/examples/recommendations/generate_budget_recommendations.py +++ b/examples/recommendations/generate_budget_recommendations.py @@ -25,6 +25,7 @@ """ import argparse +import logging import sys from typing import List, Dict, Any @@ -41,6 +42,9 @@ Recommendation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/recommendations/get_recommendation_impact_metrics.py b/examples/recommendations/get_recommendation_impact_metrics.py index 0a2c8e1be..3805ba396 100644 --- a/examples/recommendations/get_recommendation_impact_metrics.py +++ b/examples/recommendations/get_recommendation_impact_metrics.py @@ -25,6 +25,7 @@ """ import argparse +import logging import sys from typing import List, Dict, Any @@ -41,6 +42,9 @@ Recommendation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, customer_id: str, user_provided_budget_amount: int diff --git a/examples/remarketing/add_conversion_action.py b/examples/remarketing/add_conversion_action.py index 58462fd4e..36eb38b27 100755 --- a/examples/remarketing/add_conversion_action.py +++ b/examples/remarketing/add_conversion_action.py @@ -15,6 +15,7 @@ """This example illustrates adding a conversion action.""" import argparse +import logging import sys import uuid @@ -31,6 +32,9 @@ MutateConversionActionsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START add_conversion_action] def main(client: GoogleAdsClient, customer_id: str) -> None: diff --git a/examples/remarketing/add_conversion_based_user_list.py b/examples/remarketing/add_conversion_based_user_list.py index dc1ddaa25..13bf7bd8f 100644 --- a/examples/remarketing/add_conversion_based_user_list.py +++ b/examples/remarketing/add_conversion_based_user_list.py @@ -20,9 +20,10 @@ """ import argparse +import logging import sys -from uuid import uuid4 from typing import List +from uuid import uuid4 from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -39,6 +40,9 @@ MutateUserListsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START add_conversion_based_user_list] def main( diff --git a/examples/remarketing/add_custom_audience.py b/examples/remarketing/add_custom_audience.py index cc54c7413..548816f16 100755 --- a/examples/remarketing/add_custom_audience.py +++ b/examples/remarketing/add_custom_audience.py @@ -20,6 +20,7 @@ """ import argparse +import logging import sys from uuid import uuid4 @@ -40,6 +41,9 @@ CustomAudienceServiceClient, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/remarketing/add_customer_match_user_list.py b/examples/remarketing/add_customer_match_user_list.py index 57991eaf4..f68074902 100755 --- a/examples/remarketing/add_customer_match_user_list.py +++ b/examples/remarketing/add_customer_match_user_list.py @@ -28,9 +28,10 @@ import argparse import hashlib +import logging import sys -import uuid from typing import List, Dict, Optional, Union, Iterable +import uuid from google.protobuf.any_pb2 import Any from google.rpc import status_pb2 @@ -75,6 +76,9 @@ GoogleAdsError, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/remarketing/add_dynamic_remarketing_asset.py b/examples/remarketing/add_dynamic_remarketing_asset.py index 9ca8b50d2..f1aa98b21 100755 --- a/examples/remarketing/add_dynamic_remarketing_asset.py +++ b/examples/remarketing/add_dynamic_remarketing_asset.py @@ -16,6 +16,7 @@ import argparse from datetime import datetime +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -63,6 +64,9 @@ GoogleAdsServiceClient, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/remarketing/add_flexible_rule_user_list.py b/examples/remarketing/add_flexible_rule_user_list.py index 1eb3cd84a..641345332 100644 --- a/examples/remarketing/add_flexible_rule_user_list.py +++ b/examples/remarketing/add_flexible_rule_user_list.py @@ -19,6 +19,7 @@ """ import argparse +import logging import sys from uuid import uuid4 @@ -41,6 +42,9 @@ MutateUserListsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START add_combined_rule_user_list] def main(client: GoogleAdsClient, customer_id: str) -> None: diff --git a/examples/remarketing/add_logical_user_list.py b/examples/remarketing/add_logical_user_list.py index 2cd9e9d79..29010bba8 100644 --- a/examples/remarketing/add_logical_user_list.py +++ b/examples/remarketing/add_logical_user_list.py @@ -19,9 +19,10 @@ """ import argparse +import logging import sys -from uuid import uuid4 from typing import List +from uuid import uuid4 from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -38,6 +39,9 @@ MutateUserListsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START add_logical_user_list] def main( diff --git a/examples/remarketing/add_merchant_center_dynamic_remarketing_campaign.py b/examples/remarketing/add_merchant_center_dynamic_remarketing_campaign.py index 97ec08957..e32299d33 100644 --- a/examples/remarketing/add_merchant_center_dynamic_remarketing_campaign.py +++ b/examples/remarketing/add_merchant_center_dynamic_remarketing_campaign.py @@ -19,6 +19,7 @@ """ import argparse +import logging import requests import sys from uuid import uuid4 @@ -75,6 +76,9 @@ ResponsiveDisplayAdInfo, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/remarketing/set_up_advanced_remarketing.py b/examples/remarketing/set_up_advanced_remarketing.py index 3317d5085..a84382513 100644 --- a/examples/remarketing/set_up_advanced_remarketing.py +++ b/examples/remarketing/set_up_advanced_remarketing.py @@ -20,6 +20,7 @@ """ import argparse +import logging import sys from uuid import uuid4 @@ -47,6 +48,9 @@ UserListOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/remarketing/set_up_remarketing.py b/examples/remarketing/set_up_remarketing.py index 91259fefb..1e96d5cb7 100755 --- a/examples/remarketing/set_up_remarketing.py +++ b/examples/remarketing/set_up_remarketing.py @@ -25,6 +25,7 @@ """ import argparse +import logging import sys from typing import List from uuid import uuid4 @@ -76,6 +77,9 @@ UserListOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/remarketing/update_audience_target_restriction.py b/examples/remarketing/update_audience_target_restriction.py index e6d729551..bed09b8b0 100644 --- a/examples/remarketing/update_audience_target_restriction.py +++ b/examples/remarketing/update_audience_target_restriction.py @@ -15,6 +15,7 @@ """Updates the audience target restriction of a given ad group to bid only.""" import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -42,6 +43,9 @@ ) from google.api_core import protobuf_helpers +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str) -> None: """Updates the audience target restriction of a given ad group to bid only. diff --git a/examples/remarketing/upload_call_conversion.py b/examples/remarketing/upload_call_conversion.py index e2170ab32..1c2bfbdf6 100644 --- a/examples/remarketing/upload_call_conversion.py +++ b/examples/remarketing/upload_call_conversion.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import Optional @@ -37,6 +38,9 @@ from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START upload_call_conversion] def main( diff --git a/examples/remarketing/upload_conversion_adjustment.py b/examples/remarketing/upload_conversion_adjustment.py index 60f7c4e5f..39367267f 100644 --- a/examples/remarketing/upload_conversion_adjustment.py +++ b/examples/remarketing/upload_conversion_adjustment.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from typing import Optional, Iterable @@ -45,6 +46,9 @@ UploadConversionAdjustmentsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START upload_conversion_adjustment] def main( diff --git a/examples/remarketing/upload_enhanced_conversions_for_leads.py b/examples/remarketing/upload_enhanced_conversions_for_leads.py index f8c6f3269..ba651932a 100644 --- a/examples/remarketing/upload_enhanced_conversions_for_leads.py +++ b/examples/remarketing/upload_enhanced_conversions_for_leads.py @@ -22,6 +22,7 @@ import argparse import hashlib +import logging import re import sys from typing import Dict, Optional, Union @@ -44,6 +45,9 @@ UploadClickConversionsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/remarketing/upload_enhanced_conversions_for_web.py b/examples/remarketing/upload_enhanced_conversions_for_web.py index aa2a3f578..3a982ae1d 100644 --- a/examples/remarketing/upload_enhanced_conversions_for_web.py +++ b/examples/remarketing/upload_enhanced_conversions_for_web.py @@ -19,12 +19,16 @@ import argparse import hashlib +import logging import re import sys from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client, diff --git a/examples/remarketing/upload_offline_conversion.py b/examples/remarketing/upload_offline_conversion.py index 4ca0f8b1d..d61c61956 100644 --- a/examples/remarketing/upload_offline_conversion.py +++ b/examples/remarketing/upload_offline_conversion.py @@ -20,6 +20,7 @@ """ import argparse +import logging import sys from typing import Optional @@ -39,6 +40,9 @@ UploadClickConversionsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START upload_offline_conversion] def main( diff --git a/examples/remarketing/upload_store_sales_transactions.py b/examples/remarketing/upload_store_sales_transactions.py index 5e512f5ba..0b53b2859 100644 --- a/examples/remarketing/upload_store_sales_transactions.py +++ b/examples/remarketing/upload_store_sales_transactions.py @@ -21,6 +21,7 @@ import argparse from datetime import datetime import hashlib +import logging import sys from typing import List, Optional, Tuple @@ -65,6 +66,9 @@ OfflineUserDataJobOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/reporting/parallel_report_download.py b/examples/reporting/parallel_report_download.py index 2517b863e..07f6b6cf8 100644 --- a/examples/reporting/parallel_report_download.py +++ b/examples/reporting/parallel_report_download.py @@ -21,7 +21,9 @@ import argparse from itertools import product +import logging import multiprocessing +import sys import time from typing import Any, Dict, Iterable, List, Tuple @@ -39,6 +41,10 @@ SearchGoogleAdsStreamResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Maximum number of processes to spawn. MAX_PROCESSES: int = multiprocessing.cpu_count() # Timeout between retries in seconds. diff --git a/examples/shopping_ads/add_listing_scope.py b/examples/shopping_ads/add_listing_scope.py index 9f506f485..a8e234852 100755 --- a/examples/shopping_ads/add_listing_scope.py +++ b/examples/shopping_ads/add_listing_scope.py @@ -28,6 +28,7 @@ """ import argparse +import logging import sys from typing import List @@ -56,6 +57,9 @@ MutateCampaignCriteriaResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, campaign_id: str) -> None: campaign_service: CampaignServiceClient = client.get_service( diff --git a/examples/shopping_ads/add_performance_max_product_listing_group_tree.py b/examples/shopping_ads/add_performance_max_product_listing_group_tree.py index 1a52e3414..94db1d4ef 100644 --- a/examples/shopping_ads/add_performance_max_product_listing_group_tree.py +++ b/examples/shopping_ads/add_performance_max_product_listing_group_tree.py @@ -23,6 +23,7 @@ """ import argparse +import logging import sys from typing import Dict, List, Optional @@ -46,6 +47,10 @@ MutateOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # We specify temporary IDs that are specific to a single mutate request. # Temporary IDs are always negative and unique within one mutate request. # diff --git a/examples/shopping_ads/add_performance_max_retail_campaign.py b/examples/shopping_ads/add_performance_max_retail_campaign.py index ceaeabb7e..ffbc855f3 100644 --- a/examples/shopping_ads/add_performance_max_retail_campaign.py +++ b/examples/shopping_ads/add_performance_max_retail_campaign.py @@ -36,6 +36,7 @@ import argparse from datetime import datetime, timedelta +import logging import sys from typing import Dict, List, Union from uuid import uuid4 @@ -107,6 +108,10 @@ MutateOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # We specify temporary IDs that are specific to a single mutate request. # Temporary IDs are always negative and unique within one mutate request. # diff --git a/examples/shopping_ads/add_shopping_product_ad.py b/examples/shopping_ads/add_shopping_product_ad.py index 18b80b40f..dd713216b 100755 --- a/examples/shopping_ads/add_shopping_product_ad.py +++ b/examples/shopping_ads/add_shopping_product_ad.py @@ -25,6 +25,7 @@ """ import argparse +import logging import sys import uuid @@ -70,6 +71,9 @@ CampaignOperation, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/shopping_ads/add_shopping_product_listing_group_tree.py b/examples/shopping_ads/add_shopping_product_listing_group_tree.py index 0f36de255..fae34d868 100644 --- a/examples/shopping_ads/add_shopping_product_listing_group_tree.py +++ b/examples/shopping_ads/add_shopping_product_listing_group_tree.py @@ -26,6 +26,7 @@ """ import argparse +import logging import sys from typing import List, Optional @@ -58,6 +59,10 @@ SearchGoogleAdsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + last_criterion_id: int = 0 diff --git a/examples/shopping_ads/get_product_category_constants.py b/examples/shopping_ads/get_product_category_constants.py index aa73dd559..2dd2d3802 100755 --- a/examples/shopping_ads/get_product_category_constants.py +++ b/examples/shopping_ads/get_product_category_constants.py @@ -15,7 +15,7 @@ """This example fetches the set of all ProductCategoryConstants.""" import argparse -import collections +import logging import sys from typing import DefaultDict, List, Optional @@ -32,6 +32,9 @@ SearchGoogleAdsStreamResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + class Category: def __init__( diff --git a/examples/targeting/add_campaign_targeting_criteria.py b/examples/targeting/add_campaign_targeting_criteria.py index cde6bd672..2a1994392 100755 --- a/examples/targeting/add_campaign_targeting_criteria.py +++ b/examples/targeting/add_campaign_targeting_criteria.py @@ -15,8 +15,9 @@ """This example adds campaign targeting criteria.""" import argparse -from typing import List +import logging import sys +from typing import List from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException @@ -40,6 +41,9 @@ MutateCampaignCriteriaResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/targeting/add_customer_negative_criteria.py b/examples/targeting/add_customer_negative_criteria.py index d91e73c66..92dc72007 100755 --- a/examples/targeting/add_customer_negative_criteria.py +++ b/examples/targeting/add_customer_negative_criteria.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -33,6 +34,9 @@ MutateCustomerNegativeCriteriaResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str) -> None: """The main method that creates all necessary entities for the example. diff --git a/examples/targeting/add_demographic_targeting_criteria.py b/examples/targeting/add_demographic_targeting_criteria.py index 760696152..40a990a99 100755 --- a/examples/targeting/add_demographic_targeting_criteria.py +++ b/examples/targeting/add_demographic_targeting_criteria.py @@ -17,6 +17,7 @@ create ad groups, run add_ad_groups.py.""" import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -35,6 +36,9 @@ MutateAdGroupCriteriaResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str) -> None: ad_group_service: AdGroupServiceClient = client.get_service( diff --git a/examples/targeting/get_geo_target_constants_by_names.py b/examples/targeting/get_geo_target_constants_by_names.py index f8f16c6b3..293bcd15a 100755 --- a/examples/targeting/get_geo_target_constants_by_names.py +++ b/examples/targeting/get_geo_target_constants_by_names.py @@ -14,6 +14,7 @@ # limitations under the License. """This example illustrates getting GeoTargetConstants by given location names.""" +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -30,6 +31,10 @@ SuggestGeoTargetConstantsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # Locale is using ISO 639-1 format. If an invalid locale is given, # 'en' is used by default. LOCALE: str = "en" diff --git a/examples/travel/add_hotel_ad.py b/examples/travel/add_hotel_ad.py index f5397a1be..8dffeaa18 100755 --- a/examples/travel/add_hotel_ad.py +++ b/examples/travel/add_hotel_ad.py @@ -21,6 +21,7 @@ """ import argparse +import logging import sys import uuid @@ -61,6 +62,9 @@ MutateCampaignsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient, diff --git a/examples/travel/add_hotel_ad_group_bid_modifiers.py b/examples/travel/add_hotel_ad_group_bid_modifiers.py index 28008b194..d40b4f53e 100755 --- a/examples/travel/add_hotel_ad_group_bid_modifiers.py +++ b/examples/travel/add_hotel_ad_group_bid_modifiers.py @@ -18,6 +18,7 @@ """ import argparse +import logging import sys from google.ads.googleads.client import GoogleAdsClient @@ -38,6 +39,9 @@ MutateAdGroupBidModifiersResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + # [START add_hotel_ad_group_bid_modifiers] def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str) -> None: diff --git a/examples/travel/add_hotel_listing_group_tree.py b/examples/travel/add_hotel_listing_group_tree.py index 71a594179..57558e494 100755 --- a/examples/travel/add_hotel_listing_group_tree.py +++ b/examples/travel/add_hotel_listing_group_tree.py @@ -29,6 +29,7 @@ """ import argparse +import logging import sys from typing import List, Optional @@ -53,6 +54,10 @@ MutateAdGroupCriterionResult, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + # The next temporary criterion ID to be used, which is a negative integer. # # When creating a tree, we need to specify the parent-child relationships diff --git a/examples/travel/add_performance_max_for_travel_goals_campaign.py b/examples/travel/add_performance_max_for_travel_goals_campaign.py index 0bd8301bf..414ade622 100644 --- a/examples/travel/add_performance_max_for_travel_goals_campaign.py +++ b/examples/travel/add_performance_max_for_travel_goals_campaign.py @@ -36,6 +36,7 @@ """ import argparse +import logging import sys from typing import Dict, List @@ -90,6 +91,10 @@ SuggestTravelAssetsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + + MIN_REQUIRED_TEXT_ASSET_COUNTS: Dict[str, int] = { "HEADLINE": 3, "LONG_HEADLINE": 1, diff --git a/examples/travel/add_things_to_do_ad.py b/examples/travel/add_things_to_do_ad.py index 4ce89ddf5..cf5c7b32c 100755 --- a/examples/travel/add_things_to_do_ad.py +++ b/examples/travel/add_things_to_do_ad.py @@ -20,6 +20,7 @@ """ import argparse +import logging import sys from examples.utils.example_helpers import get_printable_datetime @@ -60,6 +61,9 @@ MutateCampaignsResponse, ) +logger = logging.getLogger("google.ads.googleads.client") +logger.addHandler(logging.StreamHandler(sys.stdout)) + def main( client: GoogleAdsClient,