Skip to content
Snippets Groups Projects
Commit 42a28bcf authored by marco's avatar marco
Browse files

log python output to console

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2388 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 8208ecf9
No related branches found
No related tags found
No related merge requests found
...@@ -115,7 +115,7 @@ void GostyApp::ReadLoggerSettings(const QString& group_name, TextLogger* logger) ...@@ -115,7 +115,7 @@ void GostyApp::ReadLoggerSettings(const QString& group_name, TextLogger* logger)
{ {
QSettings settings; QSettings settings;
settings.beginGroup("logging"); settings.beginGroup("logging");
settings.beginGroup(group_name); settings.beginGroup(group_name);
logger->SetCodeLogging(settings.value("log_code",QVariant(false)).toBool()); logger->SetCodeLogging(settings.value("log_code",QVariant(false)).toBool());
logger->SetOutputLogging(settings.value("log_output",QVariant(true)).toBool()); logger->SetOutputLogging(settings.value("log_output",QVariant(true)).toBool());
logger->SetErrorLogging(settings.value("log_error",QVariant(true)).toBool()); logger->SetErrorLogging(settings.value("log_error",QVariant(true)).toBool());
...@@ -127,8 +127,14 @@ void GostyApp::SetupPyShellLogging() ...@@ -127,8 +127,14 @@ void GostyApp::SetupPyShellLogging()
{ {
TextLogger* console_logger=new TextLogger(stdout); TextLogger* console_logger=new TextLogger(stdout);
this->ReadLoggerSettings("console", console_logger); this->ReadLoggerSettings("console", console_logger);
// get log from Interpreter instead of shell if (console_logger->GetErrorLogging()) {
//py_shell_->AddLogger(console_logger); 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 // TODO: Setup file logging
} }
...@@ -136,8 +142,8 @@ PythonShell* GostyApp::GetPyShell() ...@@ -136,8 +142,8 @@ PythonShell* GostyApp::GetPyShell()
{ {
if (py_shell_==NULL) { if (py_shell_==NULL) {
py_shell_=new PythonShell; py_shell_=new PythonShell;
this->SetupPyShellLogging(); this->SetupPyShellLogging();
py_shell_->SetDestroyOnClose(false); py_shell_->SetDestroyOnClose(false);
} }
return py_shell_; return py_shell_;
} }
......
...@@ -70,18 +70,9 @@ void TextLogger::AppendCode(const QString& text) ...@@ -70,18 +70,9 @@ void TextLogger::AppendCode(const QString& text)
operator<<('\n'); operator<<('\n');
flush(); 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<<(text);
operator<<('\n');
flush(); flush();
} }
void TextLogger::SetCodeLogging(bool flag) void TextLogger::SetCodeLogging(bool flag)
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
public slots: public slots:
void AppendCode(const QString& text); void AppendCode(const QString& text);
void AppendOutput(int status,const QString& text); void AppendOutput(unsigned int id,const QString& text);
protected: protected:
bool log_code_; bool log_code_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment