psweep.psweep.capture_logs_wrapper#
- psweep.psweep.capture_logs_wrapper(pset, func, capture_logs, db_field='_logs')[source]#
Capture and redirect stdout and stderr produced in func().
Note the limitations mentioned in [1]: :rtype:
dictNote that the global side effect on sys.stdout means that this context manager is not suitable for use in library code and most threaded applications. It also has no effect on the output of subprocesses. However, it is still a useful approach for many utility scripts.
So if users rely on playing with sys.stdout/stderr in func(), then they should not use this feature and take care of logging themselves.
[1] https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout