@@ -127,17 +127,18 @@ def handler(ctx, data: io.BytesIO = None):
127
127
128
128
resp = {}
129
129
resp ["Result" ] = "OK"
130
+ logger = logging .getLogger ()
130
131
131
132
# We gather the input arguments from the function configuration:
132
133
try :
133
134
cfg = dict (ctx .Config ())
134
135
compartment_ocid = cfg ["compartment_ocid" ]
135
136
region = cfg ["region" ]
136
137
except (Exception , ValueError ) as ex :
137
- logging . getLogger (). error ('ERROR: ' + str (ex ))
138
+ logger . error (str (ex ))
138
139
139
140
# Start:
140
- logging . getLogger () .info ("Starting OCI Service Metrics limits gathering and customer metrics post..." )
141
+ logger .info ("Starting OCI Service Metrics limits gathering and customer metrics post..." )
141
142
142
143
# Setup the signer for the resource principals auth method
143
144
signer = oci .auth .signers .get_resource_principals_signer ()
@@ -154,19 +155,19 @@ def handler(ctx, data: io.BytesIO = None):
154
155
break
155
156
else :
156
157
resp ["Result" ] = "NOT OK"
157
- resp ["ERROR" ] = "Wrong or non-subscribed OCI region"
158
- logging . getLogger (). error ('ERROR: Wrong or non-subscribed OCI region' )
158
+ resp ["ERROR" ] = "Wrong or non-subscribed OCI region. "
159
+ logger . error ('Wrong or non-subscribed OCI region. ' )
159
160
exit (1 )
160
161
except (Exception , ValueError ) as ex :
161
- logging . getLogger (). error ('ERROR: ' + str (ex ))
162
+ logger . error (str (ex ))
162
163
163
164
164
165
# Check tenancy compartment OCID given
165
166
try :
166
167
list_availability_domains_response = identity_client .list_availability_domains (compartment_id = compartment_ocid )
167
168
except Exception as ex :
168
169
resp ["Result" ] = "NOT OK"
169
- resp ["ERROR" ] = "The given compartment is wrong or you aren't authorized to list the availability domains"
170
+ resp ["ERROR" ] = "The given compartment is wrong or you aren't authorized to list the availability domains. "
170
171
exit (1 )
171
172
172
173
service_endpoint = "https://telemetry-ingestion." + region + ".oraclecloud.com"
@@ -240,5 +241,5 @@ def handler(ctx, data: io.BytesIO = None):
240
241
241
242
242
243
# Finish:
243
- logging . getLogger () .info ("Finish OCI Service Metrics limits gathering and customer metrics post." )
244
+ logger .info ("Finish OCI Service Metrics limits gathering and customer metrics post." )
244
245
return resp
0 commit comments