4545
4646#include < openfluid/ui/waresdev/GitUIProxy.hpp>
4747#include < openfluid/base/Environment.hpp>
48- #include < openfluid/utils/ExternalProgram.hpp>
4948#include < openfluid/tools/FilesystemPath.hpp>
49+ #include < openfluid/utils/ExternalProgram.hpp>
50+ #include < openfluid/utils/InternalLogger.hpp>
5051#include < openfluid/config.hpp>
5152
5253
@@ -137,9 +138,9 @@ bool GitUIProxy::launchAuthCommand(QStringList Args, const QString& FromUrl, con
137138{
138139 if (FromUrl.isEmpty () || ToPath.isEmpty ())
139140 {
140- // TODO for non GUI interface, find a way to redirect error/info
141- // std::cout << "Empty remote url or empty destination path" << std::endl ;
142- emit error (tr (" Empty remote url or empty destination path " ));
141+ std::string ErrorMsg = " Empty remote url or empty destination path " ;
142+ openfluid::utils::log::error ( " Git " , ErrorMsg) ;
143+ emit error (tr (ErrorMsg. c_str () ));
143144 return false ;
144145 }
145146
@@ -151,12 +152,15 @@ bool GitUIProxy::launchAuthCommand(QStringList Args, const QString& FromUrl, con
151152 openfluid::tools::FilesystemPath ({WorkingDirectory.toStdString (), " .git" , " index.lock" });
152153 if (GitIndexLockPath.exists ())
153154 {
154- // std::cout << "Can not operate, git lock detected:" << std::endl;
155- emit error (tr (" Can not operate, git lock detected." ));
155+ std::string ErrorMsg = " Can not operate, git lock detected." ;
156+ openfluid::utils::log::error (" Git" , ErrorMsg);
157+ emit error (tr (ErrorMsg.c_str ()));
156158 return false ;
157159 }
158160 else // HACK for debugging purpose, to remove before release
159161 {
162+ openfluid::utils::log::debug (" Git" ,
163+ " git lock not detected here: " +WorkingDirectory.toStdString ());
160164 emit info (tr (" git lock not detected here:" )+QString::fromStdString (WorkingDirectory.toStdString ()));
161165 }
162166 }
@@ -202,30 +206,35 @@ bool GitUIProxy::launchAuthCommand(QStringList Args, const QString& FromUrl, con
202206 connect (mp_Process, SIGNAL (readyReadStandardOutput ()), this , SLOT (processStandardOutput ()));
203207 connect (mp_Process, SIGNAL (readyReadStandardError ()), this , SLOT (processErrorOutputAsInfo ()));
204208
205- // TO BE USED IN INTERNAL LOGGING STACK AS "INFO"
206- // std::cout << "PROCESS START:" << m_LocalGitProgram << " : ";
207- // for (auto& p : Args)
208- // {
209- // std::cout << " " << p.toStdString() << std::endl;
210- // }
211- // std::cout << std::endl ;
209+ std::string GitCommand = m_LocalGitProgram + " " ;
210+ for ( auto & p : Args)
211+ {
212+ GitCommand += " " + p. toStdString ();
213+ }
214+
215+ openfluid::utils::log::info ( " Git " , GitCommand) ;
212216 mp_Process->start (QString::fromStdString (m_LocalGitProgram),Args);
213217 if (!mp_Process->waitForStarted ())
214218 {
215219 delete mp_Process;
216220 mp_Process = nullptr ;
217- // std::cout << " failed start:" << std::endl; TODO add to logging
221+ openfluid::utils::log::error ( " Git " , " Git failed start" );
218222 return false ;
219223 }
220- // std::cout << "PROCESS POST START" << std::endl;
221224 mp_Process->waitForFinished (-1 );
222225 mp_Process->waitForReadyRead (-1 );
223226
224227 QString Res = QString::fromUtf8 (mp_Process->readAll ());
228+
229+ std::string ResContent = Res.toStdString ();
230+ if (ResContent.empty ())
231+ {
232+ ResContent = " /EMPTY/" ;
233+ }
234+ openfluid::utils::log::debug (" Git" ,
235+ " Git process content: " +ResContent);
225236
226- // std::cout << "PROCESS READ" << Res.toStdString() << std::endl;
227237 int ErrCode = mp_Process->exitCode ();
228- // !std::cout << "EXIT:" << ErrCode << std::endl;
229238
230239 delete mp_Process;
231240 mp_Process = nullptr ;
@@ -342,7 +351,7 @@ std::pair<bool, QString> GitUIProxy::removeSubmodule(const QString& MainPathStr
342351 {
343352 StandardOutput += tr (" Submodule successfully removed" );
344353 }
345- // TODO for logging system std::cout << "OUT IN REMOVE:" << StandardOutput.toStdString() << std::endl ;
354+ openfluid::utils::log::debug ( " Git " , StandardOutput.toStdString ()) ;
346355 return std::pair (SummaryStatusCode, StandardOutput);
347356}
348357
0 commit comments