File size: 740 Bytes
dd74f4c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import os
def make_logging_client():
cred_filename = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS')
if not cred_filename:
return None
print("cred filename:", cred_filename)
cred_string = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS_STRING')
print("cred string:", bool(cred_string))
if not os.path.exists(cred_filename):
if cred_string:
print(f"writing cred string to {cred_filename}")
with open(cred_filename, 'w') as f:
f.write(cred_string)
else:
return None
from google.cloud import logging
logging_client = logging.Client()
logging_client.setup_logging()
return logging_client
logging_client = make_logging_client()
|