MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / redirect_output

Function redirect_output

src/python/runner.cpp:113–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 static void redirect_output() {
114 const char* redirect_code = R"(
115import sys
116import _lfs_output
117
118class 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
127sys.stdout = OutputCapture(False)
128sys.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);

Callers 2

install_output_redirectFunction · 0.85
run_scriptsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected