Skip to content
Permalink
Browse files
feat: use structured logging on GCF with python 3.7 (#434)
  • Loading branch information
daniel-sanche committed Nov 1, 2021
1 parent 9d38995 commit 5055919f70c82b38de6d1fa7f1df6006865a857b
Showing with 4 additions and 8 deletions.
  1. +3 −7 google/cloud/logging_v2/client.py
  2. +1 −1 tests/environment
@@ -355,13 +355,9 @@ def get_default_handler(self, **kw):
return AppEngineHandler(self, **kw)
elif monitored_resource.type == _GKE_RESOURCE_TYPE:
return ContainerEngineHandler(**kw)
elif (
monitored_resource.type == _GCF_RESOURCE_TYPE
and sys.version_info[0] == 3
and sys.version_info[1] >= 8
):
# Cloud Functions with runtimes > 3.8 supports structured logs on standard out
# 3.7 should use the standard CloudLoggingHandler, which sends logs over the network.
elif monitored_resource.type == _GCF_RESOURCE_TYPE:
# __stdout__ stream required to support structured logging on Python 3.7
kw["stream"] = kw.get("stream", sys.__stdout__)
return StructuredLogHandler(**kw, project_id=self.project)
elif monitored_resource.type == _RUN_RESOURCE_TYPE:
return StructuredLogHandler(**kw, project_id=self.project)

0 comments on commit 5055919

Please sign in to comment.