]> WPIA git - cassiopeia.git/blobdiff - src/util.cpp
chg: Modify the code to use the new logger
[cassiopeia.git] / src / util.cpp
index c16ba1c6c8d541164fc5ff7fd540aadb74d1e7fa..a052843561302edcf1869df1250bcf11dca04a80 100644 (file)
@@ -182,20 +182,24 @@ std::pair<bool, time_t> parseYearInterval( std::time_t t, const std::string& dat
     }
 }
 
-std::shared_ptr<std::ofstream> openLogfile( const std::string name) {
+std::shared_ptr<std::ofstream> openLogfile( const std::string name ) {
     struct stat buffer;
     std::string tname = name;
     int ctr = 2;
-    while(stat (tname.c_str(), &buffer) == 0) {
-        tname = name + "_" + std::to_string(ctr++);
+
+    while( stat( tname.c_str(), &buffer ) == 0 ) {
+        tname = name + "_" + std::to_string( ctr++ );
     }
-    auto res = std::shared_ptr<std::ofstream>(new std::ofstream( tname ),
-        [](std::ofstream *p){
+
+    auto res = std::shared_ptr<std::ofstream>( new std::ofstream( tname ),
+        []( std::ofstream * p ) {
             p->close();
             delete p;
-        });
-    if(! res->good() ){
-        throw std::string("Failed to open file for logging: ") + name;
+        } );
+
+    if( ! res->good() ) {
+        throw std::string( "Failed to open file for logging: " ) + name;
     }
+
     return res;
 }