]> WPIA git - cassiopeia.git/blobdiff - src/apps/client.cpp
add: better logfile opening, better connection ending
[cassiopeia.git] / src / apps / client.cpp
index 3d4c339907e9f0a38391a6b73e3d40a03f23ab8b..5cbacdc264481a1e13515825eae6bc88fe801042 100644 (file)
@@ -107,14 +107,9 @@ int main( int argc, const char* argv[] ) {
             continue;
         }
 
-        std::ofstream* logP = new std::ofstream( std::string( "logs/" ) + job->id + std::string( "_" ) + job->warning + std::string( ".log" ) );
-        std::shared_ptr<std::ofstream> logPtr(
-            logP,
-            []( std::ofstream * ptr ) {
-                ( *ptr ).close();
-                delete ptr;
-            } );
-        std::ofstream& log = *logP;
+        std::shared_ptr<std::ofstream> logPtr = openLogfile( std::string( "logs/" ) + job->id + std::string( "_" ) + job->warning + std::string( ".log" ) );
+
+        std::ofstream& log = *( logPtr.get() );
 
         sign->setLog( logPtr );
         log << "TASK ID: " << job->id << std::endl;
@@ -202,6 +197,8 @@ int main( int argc, const char* argv[] ) {
                 jp->finishJob( job );
             } catch( const char* c ) {
                 std::cout << "Exception: " << c << std::endl;
+            } catch( const std::string& c ) {
+                std::cout << "Exception: " << c << std::endl;
             }
         } else {
             log << "Unknown job type" << job->task << std::endl;