bigcode/bigcode-editor
54
1import os2def make_logging_client():3 cred_filename = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS')4 if not cred_filename:5 return None6 print("cred filename:", cred_filename)7 cred_string = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS_STRING')8 print("cred string:", bool(cred_string))9 if not os.path.exists(cred_filename):10 if cred_string:11 print(f"writing cred string to {cred_filename}")12 with open(cred_filename, 'w') as f:13 f.write(cred_string)14 else:15 return None16 from google.cloud import logging17 logging_client = logging.Client()18 logging_client.setup_logging()19 return logging_client20 21logging_client = make_logging_client()22 