diff --git a/modules/gui/src/gosty_app.cc b/modules/gui/src/gosty_app.cc index 7090e7449d5ad5948e6c3361547560947d39a30b..91216a846132507ee2a96e4462fd5b36b3fd70d8 100644 --- a/modules/gui/src/gosty_app.cc +++ b/modules/gui/src/gosty_app.cc @@ -115,7 +115,7 @@ void GostyApp::ReadLoggerSettings(const QString& group_name, TextLogger* logger) { QSettings settings; settings.beginGroup("logging"); - settings.beginGroup(group_name); + settings.beginGroup(group_name); logger->SetCodeLogging(settings.value("log_code",QVariant(false)).toBool()); logger->SetOutputLogging(settings.value("log_output",QVariant(true)).toBool()); logger->SetErrorLogging(settings.value("log_error",QVariant(true)).toBool()); @@ -127,8 +127,14 @@ void GostyApp::SetupPyShellLogging() { TextLogger* console_logger=new TextLogger(stdout); this->ReadLoggerSettings("console", console_logger); - // get log from Interpreter instead of shell - //py_shell_->AddLogger(console_logger); + if (console_logger->GetErrorLogging()) { + connect(&PythonInterpreter::Instance(), SIGNAL(ErrorOutput(unsigned int, const QString &)), + console_logger,SLOT(AppendOutput(unsigned int, const QString &))); + } + if (console_logger->GetOutputLogging()) { + connect(&PythonInterpreter::Instance(), SIGNAL(Output(unsigned int, const QString &)), + console_logger,SLOT(AppendOutput(unsigned int, const QString &))); + } // TODO: Setup file logging } @@ -136,8 +142,8 @@ PythonShell* GostyApp::GetPyShell() { if (py_shell_==NULL) { py_shell_=new PythonShell; - this->SetupPyShellLogging(); - py_shell_->SetDestroyOnClose(false); + this->SetupPyShellLogging(); + py_shell_->SetDestroyOnClose(false); } return py_shell_; } diff --git a/modules/gui/src/python_shell/text_logger.cc b/modules/gui/src/python_shell/text_logger.cc index ef0dee5780eb97e82b61245ba77cc35b21f053bb..04123b9a7c85cee05510df0c93a943f24ec158a5 100644 --- a/modules/gui/src/python_shell/text_logger.cc +++ b/modules/gui/src/python_shell/text_logger.cc @@ -70,18 +70,9 @@ void TextLogger::AppendCode(const QString& text) operator<<('\n'); flush(); } -void TextLogger::AppendOutput(int status,const QString& text) +void TextLogger::AppendOutput(unsigned int id,const QString& text) { - if (text=="\n") { - return; - } - if(!((log_output_ && status==STATUS_OK) || (log_error_ && status==STATUS_ERROR)) - || text.size()==0){ - return; - } - operator<<(text); - operator<<('\n'); flush(); } void TextLogger::SetCodeLogging(bool flag) diff --git a/modules/gui/src/python_shell/text_logger.hh b/modules/gui/src/python_shell/text_logger.hh index 1be25f652f9f4212e1a9992f33ee00f0001c9d18..9e46fc7401dc73fdbc4f6e2474500c3ef602c8be 100644 --- a/modules/gui/src/python_shell/text_logger.hh +++ b/modules/gui/src/python_shell/text_logger.hh @@ -49,7 +49,7 @@ public: public slots: void AppendCode(const QString& text); - void AppendOutput(int status,const QString& text); + void AppendOutput(unsigned int id,const QString& text); protected: bool log_code_;