Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

cannot log google ads logging v19 python client

未关闭
#557 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
api

调研方向

首先,使用 google-ads 26.1.0 复现提供的 Python 3.12.9 示例,重点关注 logging.basicConfig 和 google.ads.googleads.client。比较使用 v17 与 v19 请求服务时的日志行为;当 v19 产生预期的 Google Ads 日志时即表示完成。

由索引模型根据 Issue 内容生成。

描述

Hi Google Ads team,

Since upgrading Google Ads API version to v19, I cannot get the Google Ads logging.

import asyncio
import logging
from google.protobuf.json_format import MessageToDict

logging.basicConfig(level=logging.INFO, format='[%(asctime)s - %(levelname)s] %(message).5000s')
logging.getLogger('google.ads.googleads.client').setLevel(logging.INFO)

import google.ads.googleads.client


def setup_google_ads_connection():
    google_ads_client = (
        google.ads.googleads.client.GoogleAdsClient.load_from_storage("googleads.yaml")
    )
    ga_service = google_ads_client.get_service("GoogleAdsService", version="v19")
    return google_ads_client, ga_service


async def main(google_ads_client, google_ads_service):
    cust_list = ["2978713003"]
    for cust_id in cust_list:
        asset_query = "SELECT segments.date,[campaign.id](http://campaign.id/),[ad_group.id](http://ad_group.id/),metrics.impressions,metrics.clicks,metrics.cost_micros,asset_field_type_view.field_type,metrics.video_views,metrics.cross_device_conversions FROM asset_field_type_view  WHERE segments.date >= '2025-03-05' AND segments.date <= '2025-03-05' AND metrics.impressions > 0 AND [campaign.id](http://campaign.id/) in ('21080449403')"
        setting = google_ads_client.get_type('SummaryRowSettingEnum').SummaryRowSetting.SUMMARY_ROW_WITH_RESULTS
        search_request = google_ads_client.get_type("SearchGoogleAdsStreamRequest")
        search_request.customer_id = cust_id
        search_request.query = asset_query
        search_request.summary_row_setting = setting
        _CLIENT_TIMEOUT_SECONDS = 400
        
        stream = google_ads_service.search_stream(
            search_request, 
            timeout=_CLIENT_TIMEOUT_SECONDS
        )
        result = []
        summary_result = []
        for batch in stream:
            summary_row = batch.summary_row
            summary_row = MessageToDict(
                    summary_row,
                    use_integers_for_enums=False,
                    preserving_proto_field_name=True
                )
            summary_result.append(summary_row)
            for row in batch.results:
                row = MessageToDict(
                    row,
                    use_integers_for_enums=False,
                    preserving_proto_field_name=True
                )
                result.append(row)

                
        if result:
            print(f"{cust_id} has data")

if __name__ == "__main__":
    google_ads_client, google_ads_service = setup_google_ads_connection()

    asyncio.run(
        main(google_ads_client, google_ads_service)
    )

I use python 3.12.9
Here's the version of library used in python when pip freeze

aiohttp==3.9.5
aiosignal==1.3.2
attrs==25.3.0
boto3==1.34.126
botocore==1.34.126
cachetools==5.5.2
certifi==2025.1.31
charset-normalizer==3.4.1
frozenlist==1.6.0
google-ads==26.1.0
google-api-core==2.24.2
google-auth==2.39.0
google-auth-oauthlib==1.2.2
googleapis-common-protos==1.70.0
googlemaps==4.10.0
grpcio==1.71.0
grpcio-status==1.62.3
idna==3.10
iso3166==2.1.1
jmespath==1.0.1
multidict==6.4.3
numpy==2.2.5
oauthlib==3.2.2
pandas==2.2.2
propcache==0.3.1
proto-plus==1.26.1
protobuf==4.25.7
psycopg2-binary==2.9.10
pyasn1==0.6.1
pyasn1_modules==0.4.2
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
redis==5.1.1
requests==2.32.3
requests-oauthlib==2.0.0
rsa==4.9.1
s3transfer==0.10.4
six==1.17.0
tzdata==2025.2
ujson==5.10.0
urllib3==2.4.0
uvloop==0.19.0
yarl==1.20.0

P/S: when I use v17, the logging is normal.

Can you guide me through the steps to get Google Ads logging again?

主要语言
Python
星标
749
派生
967
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleads/googleads-python-lib 的其他 Issue

查看 googleads/googleads-python-lib 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。