I am trying to use logging's memory handler to buffer log messages to my actual logging handler. You use the memory handler by instantiating it with some arguments, like this:
import logging
buffered_handler = logging.handlers.MemoryHandler(capacity=5,target=myActualHandler)
However, I don't want my application to have to instantiate a handler from logging directly, or pass any of the arguments; I'd like this code to look like this:
import myhandlers
buffered_handler = myhandlers.BufferedRemoteHandler()
The question is: how do I do this? I'd like an attempt to instantiate my BufferedRemoteHandler to actually return logging's MemoryHandler with some specific arguments. I thought of just making BufferedRemoteHandler a function which returns the handler I want; is that the correct way? Is there a way to create a class which, when you instantiate it, actually returns a totally different class?