I have a template return logger like this
class MyLog(object):
def __init__(self, call_filename=None):
self._caller_filename = call_filename
def producer_log(self):
logger.add(f"Log/{self.caller_filename}/{{time:YYYY-MM-DD}}.log", level="DEBUG",
backtrace=True, diagnose=True, rotation='00:00', enqueue=True, compression="zip")
logger.add(f"Log/task_wrong/{{time:YYYY-MM-DD}}.log", level="DEBUG",
backtrace=True, diagnose=True, rotation='00:00', enqueue=True, compression="zip",
filter=lambda record: "special" in record["extra"],
format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | {file}:{function}:{line} - {message}")
task_error_log = logger.bind(special=True)
return logger, task_error_log
And another py file 'test.py' use this function producer_log.As you see,i need send a call_filename to MyLog,so i take it in class of test.py.However,i cant use the decorator logger.catch in test.py which return by producer_log function
class Task(object):
def __init__(self,filepath):
self.logger, self.task_error_log = MyLog(filepath).producer_log()
I have tried take function producer_log out of class ,but i need send call_filename,so it's not work