I have imported Logger
class and I have many calls to Logger.error(msg, *args, **kwargs)
or Logger.info(msg, *args, **kwargs)
in my code.
I want to make those functions (each of the Logger.error/info/warning...
) do something else (such as call another function), without changing the calls themeselvs (hundreds of calls).
I that class was something I maintain, I would do something like this:
Change this
class Logger:
def write(...):
into this:
class Logger:
def write(...):
#rename original write to _write and call it from here
self._write()
# call new function
and in this way, each call to Logger.write() would keep its old API, but will have an added functionality I desire.
How can I do something like this with a class I can't control?