(fix) allow using more than 1 custom callback

This commit is contained in:
ishaan-jaff 2023-10-19 08:57:28 -07:00
parent 5cf3c3dc86
commit 16f598aa3f

View file

@ -10,11 +10,10 @@ import traceback
class CustomLogger:
# Class variables or attributes
def __init__(self, callback_func):
# Instance variables
self.callback_func = callback_func
def __init__(self):
pass
def log_input_event(self, model, messages, kwargs, print_verbose):
def log_input_event(self, model, messages, kwargs, print_verbose, callback_func):
try:
print_verbose(
f"Custom Logger - Enters logging function for model {kwargs}"
@ -22,7 +21,7 @@ class CustomLogger:
kwargs["model"] = model
kwargs["messages"] = messages
kwargs["log_event_type"] = "pre_api_call"
self.callback_func(
callback_func(
kwargs,
)
print_verbose(
@ -32,14 +31,14 @@ class CustomLogger:
traceback.print_exc()
print_verbose(f"Custom Logger Error - {traceback.format_exc()}")
def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose):
def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose, callback_func):
# Method definition
try:
print_verbose(
f"Custom Logger - Enters logging function for model {kwargs}"
)
kwargs["log_event_type"] = "post_api_call"
self.callback_func(
callback_func(
kwargs, # kwargs to func
response_obj,
start_time,