]> SALOME platform Git repositories - tools/libbatch.git/blobdiff - src/Slurm/BatchManager_Slurm.cxx
Salome HOME
Add very simple log system
[tools/libbatch.git] / src / Slurm / BatchManager_Slurm.cxx
index dfce7cd0063d0b41e20d8c4b4f4235a1ef2c5a86..13cb2a62405d0a39f3331370882e2910af226e7f 100644 (file)
@@ -32,6 +32,7 @@
 #include <NotYetImplementedException.hxx>
 #include <Constants.hxx>
 #include <Utils.hxx>
+#include <Log.hxx>
 
 #include "BatchManager_Slurm.hxx"
 #include "JobInfo_Slurm.hxx"
@@ -69,12 +70,12 @@ namespace Batch {
     string subCommand = string("cd ") + workDir + "; sbatch " + cmdFile;
     string command = _protocol.getExecCommand(subCommand, _hostname, _username);
     command += " 2>&1";
-    cout << command.c_str() << endl;
+    LOG(command);
 
     // submit job
     string output;
     int status = Utils::getCommandOutput(command, output);
-    cout << output;
+    LOG(output);
     if (status != 0) throw RunTimeException("Can't submit job, error was: " + output);
 
     // find id of submitted job in output
@@ -180,7 +181,7 @@ namespace Batch {
     tempOutputFile.flush();
     tempOutputFile.close();
 
-    cerr << "Batch script file generated is: " << tmpFileName << endl;
+    LOG("Batch script file generated is: " << tmpFileName);
 
     string remoteFileName = rootNameToExecute + "_slurm.cmd";
     int status = _protocol.copyFile(tmpFileName, "", "",
@@ -197,13 +198,13 @@ namespace Batch {
     // define command to delete job
     string subCommand = "scancel " + jobid.getReference();
     string command = _protocol.getExecCommand(subCommand, _hostname, _username);
-    cerr << command.c_str() << endl;
+    LOG(command);
 
     int status = system(command.c_str());
     if (status)
       throw RunTimeException("Can't delete job " + jobid.getReference());
 
-    cerr << "job " << jobid.getReference() << " killed" << endl;
+    LOG("job " << jobid.getReference() << " killed");
   }
 
   JobInfo BatchManager_Slurm::queryJob(const JobId & jobid)
@@ -211,7 +212,7 @@ namespace Batch {
     // define command to query batch
     string subCommand = "squeue -o %t -j " + jobid.getReference();
     string command = _protocol.getExecCommand(subCommand, _hostname, _username);
-    cerr << command.c_str() << endl;
+    LOG(command);
     string output;
     Utils::getCommandOutput(command, output);
     // We don't test the return code here because with jobs finished since a long time Slurm