问题描述
我的(python)程序退出时,Google云日志记录正在打印此消息:
Program shutting down,attempting to send 1 queued log entries to Stackdriver Logging...
Waiting up to 5 seconds.
Sent all pending logs.
我想禁止打印该消息。是否有配置设置来控制程序退出时是否不会打印出以上消息?谢谢。
解决方法
使用 SyncTransport 而不是默认的 BackgroundThreadTransport
from google.cloud.logging_v2.handlers import CloudLoggingHandler
from google.cloud.logging_v2.handlers.transports import SyncTransport
..........
client = google.cloud.logging.Client()
handler = CloudLoggingHandler(client,name="your_log_name",transport=SyncTransport)