24 lines
765 B
Python
24 lines
765 B
Python
import logging
|
|
|
|
def buildLog (action, outputs, response):
|
|
if hasattr(action, "prints"):
|
|
try:
|
|
for print_name, print_key in action.prints.items():
|
|
print(
|
|
f"{print_name}:",
|
|
f"{outputs[print_key]}",
|
|
)
|
|
|
|
except: (KeyError, TypeError)
|
|
|
|
if action.showstatus is True and response.status_code in [200, 204]:
|
|
print(f"{action.name} successful")
|
|
|
|
elif action.showstatus is True and response.status_code not in [200, 204]:
|
|
print(f"{action.name} failed with status code {response.status_code}")
|
|
try:
|
|
print(f"Response: {response.json()["error"]}")
|
|
except KeyError:
|
|
print(f"Response:", response.json())
|
|
return
|