11 #include <framework/logging/LogConnectionConsole.h>
12 #include <framework/logging/LogMessage.h>
13 #include <boost/python.hpp>
14 #include <boost/algorithm/string.hpp>
26 m_fd(dup(outputFD)), m_color(color)
29 if (
m_fd < 0)
throw std::runtime_error(std::string(
"Error duplicating file descriptor: ") + std::strerror(errno));
45 const bool isTTY = isatty(fileDescriptor);
46 const std::string termName = getenv(
"TERM") ? getenv(
"TERM") :
"";
47 const bool useColor = isTTY and
48 (termName ==
"xterm" or termName ==
"xterm-color" or termName ==
"xterm-256color" or
49 termName ==
"sceen" or termName ==
"screen-256color" or termName ==
"tmux" or
50 termName ==
"tmux-256color" or termName ==
"rxvt-unicode" or
51 termName ==
"rxvt-unicode-256color" or termName ==
"linux" or termName ==
"cygwin");
58 auto pymessage = boost::python::import(
"sys").attr(
"stdout");
59 pymessage.attr(
"write")(message);
60 pymessage.attr(
"flush")();
70 std::stringstream stream;
72 const std::string color_str[] = {
80 const std::string& c{color_str[message.getLogLevel()]};
84 std::string messagestr = stream.str();
87 boost::trim_right_if(messagestr, boost::is_any_of(
" \t\n\r"));
89 boost::replace_all(messagestr,
"\n",
"\\n");
94 messagestr +=
"\x1b[m";
105 boost::python::import(
"sys").attr(
"stdout").attr(
"flush")();