29#ifdef TYTI_PYLOGHOOK_USE_BOOST
30#include <boost/python.hpp>
32#include "nanobind/nanobind.h"
40#ifdef TYTI_PYLOGHOOK_USE_BOOST
44 return boost::python::object(boost::python::make_function(
46 boost::python::default_call_policies(),
47 boost::mpl::vector<void, const char*>()
54 return nanobind::cpp_function(std::forward<T>(t));
61 assert(Py_IsInitialized());
63 PyObject* out = PySys_GetObject(pipename);
69 if (out == NULL || out == Py_None)
71 std::string register_read_write = std::string(
"import sys\n\
72sys.") + pipename + std::string(
" = type(\"\",(object,),{\"write\":lambda self, txt: None, \"flush\":lambda self: None})()\n");
74 PyRun_SimpleString(register_read_write.c_str());
75 out = PySys_GetObject(pipename);
78 PyObject_SetAttrString(out,
"write",
Definition PyLogHook.h:38
nanobind::object LogHookMakeObject(T t)
Definition PyLogHook.h:52
void redirect_syspipe(T t, const char *pipename)
Definition PyLogHook.h:59
Definition PyLogHook.h:37
void redirect_stderr(T t)
Definition PyLogHook.h:106
void redirect_stdout(T t)
redirects sys.stdout
Definition PyLogHook.h:100
Definition PyLogHook.h:36