Consilidate logger
This commit is contained in:
parent
68e0cff28b
commit
7d7a2699cc
@ -229,6 +229,7 @@ class CtelViewSet(viewsets.ViewSet):
|
||||
"invoice": invoice_file_objs
|
||||
}
|
||||
rq_id = provider_code + "_" + datetime.now().strftime("%Y%m%d%H%M%S") + "_" + uuid.uuid4().hex
|
||||
logger.info(f"Creating a request: {rq_id}")
|
||||
is_test_request = validated_data.get("is_test_request", False)
|
||||
count = 0
|
||||
doc_files_with_type = []
|
||||
|
@ -7,10 +7,10 @@ class VerboseTask(Task):
|
||||
|
||||
def on_failure(self, exc, task_id, args, kwargs, einfo):
|
||||
# Task failed. What do you want to do?
|
||||
logger.error('FAILURE: Task raised an exception: {}'.format(exc))
|
||||
logger.error(f'FAILURE: Task: {self.name} - {task_id} | Task raised an exception: {exc}')
|
||||
|
||||
def on_success(self, retval, task_id, args, kwargs):
|
||||
logger.info(f"SUCCESS: Task: {task_id} succeeded | retval: {retval} | args: {args} | kwargs: {kwargs}")
|
||||
logger.info(f"SUCCESS: Task: {self.name} - {task_id} | retval: {retval} | args: {args} | kwargs: {kwargs}")
|
||||
|
||||
def before_start(self, task_id, args, kwargs):
|
||||
logger.info(f"BEFORE_START: Task: {task_id} | args: {args} | kwargs: {kwargs}")
|
||||
logger.info(f"BEFORE_START: Task: {self.name} - {task_id} | args: {args} | kwargs: {kwargs}")
|
@ -20,7 +20,11 @@ class LoggingMiddleware(MiddlewareMixin):
|
||||
|
||||
def process_response(self, request, response):
|
||||
trace_id = request.META.get('X-Trace-ID', str(uuid.uuid4()))
|
||||
try:
|
||||
response_body = response.content.decode("utf-8") if response.content else ""
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
response_body = ""
|
||||
|
||||
logger.info(f"Response: {request.method} {request.path} | Trace ID: {trace_id} | "
|
||||
f"Status: {response.status_code} | Body: {response_body}")
|
||||
|
Loading…
Reference in New Issue
Block a user