psweep.psweep.capture_logs_wrapper

psweep.psweep.capture_logs_wrapper#

psweep.psweep.capture_logs_wrapper(pset, worker, capture_logs, db_field='_logs')[source]#

Capture and redirect stdout and stderr produced in worker().

Note the limitations mentioned in [1]: :rtype: dict

Note 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 worker(), then they sould not use this feature and take care of logging themselves.

[1] https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout