Files
rmmanager/core/runtime/logs.py
T

31 lines
896 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):
pass
if action.showstatus is True and response.ok:
print(f"{action.name} successful")
elif action.showstatus is True and not response.ok:
print(f"{action.name} failed with status code {response.status_code}")
try:
response_data = response.json()
except ValueError:
response_data = response.text
if isinstance(response_data, dict):
print("Response:", response_data.get("error", response_data))
else:
print("Response:", response_data)
return