C ++
I have a logger class in C ++. This registrar is heavily used in my library. The recorder allows you to set a standard STL stream for use as an output stream.
Python
A Python library using the "above SWIG-wrapped C ++ library" uses a standard python entry using StreamHandler. Sort of:
logger = logging.getLogger("base_logger") #create and set console handler ch = logging.StreamHandler() ch.stream = sys.stdout logger.addHandler(ch)
How to pass python stream to C ++ library as STL stream using SWIG?
This way you can use C ++ to use your python stream. Sort of:
ch = logger.handlers[NEEDED_HANDLER] Swig_wrapped_lib.set_stream(ch.stream)
source share