| 111 | } |
| 112 | |
| 113 | static void redirect_output() { |
| 114 | const char* redirect_code = R"( |
| 115 | import sys |
| 116 | import _lfs_output |
| 117 | |
| 118 | class OutputCapture: |
| 119 | def __init__(self, is_stderr=False): |
| 120 | self._is_stderr = 1 if is_stderr else 0 |
| 121 | def write(self, text): |
| 122 | if text: |
| 123 | _lfs_output.write(text, self._is_stderr) |
| 124 | def flush(self): |
| 125 | pass |
| 126 | |
| 127 | sys.stdout = OutputCapture(False) |
| 128 | sys.stderr = OutputCapture(True) |
| 129 | )"; |
| 130 | PyRun_SimpleString(redirect_code); |
| 131 | LOG_DEBUG("Python output redirect installed"); |
| 132 | } |
| 133 | |
| 134 | void set_output_callback(std::function<void(const std::string&, bool)> callback) { |
| 135 | std::lock_guard lock(g_output_mutex); |
no outgoing calls
no test coverage detected