]> WPIA git - cassiopeia.git/blobdiff - src/apps/signer.cpp
chg: Modify the code to use the new logger
[cassiopeia.git] / src / apps / signer.cpp
index 0d027c0a8070a44823aec9f70adf3399fed96211..3468eb274d6697c6cf399aefdcc81df182c98bd9 100644 (file)
@@ -1,6 +1,7 @@
 #include <iostream>
 #include <fstream>
 #include <streambuf>
+#include <stdexcept>
 
 #include "db/database.h"
 #include "db/mysql.h"
@@ -10,6 +11,7 @@
 #include "io/bios.h"
 #include "io/slipBio.h"
 #include "io/recordHandler.h"
+#include "log/logger.hpp"
 #include "util.h"
 #include "config.h"
 
@@ -21,7 +23,7 @@
 
 extern std::string serialPath;
 
-int main( int argc, const char* argv[] ) {
+int main( int argc, const char* argv[] ) try {
     ( void ) argc;
     ( void ) argv;
 
@@ -34,13 +36,14 @@ int main( int argc, const char* argv[] ) {
 #endif
 
     if( parseConfig( path ) != 0 ) {
+        logger::fatal("Could not parse configuration file.");
         return -1;
     }
 
     std::shared_ptr<int> ssl_lib = ssl_lib_ref;
 
     if( serialPath == "" ) {
-        std::cout << "Error: no serial device is given" << std::endl;
+        logger::fatal( "Error: No device for the serial connection was given." );
         return -1;
     }
 
@@ -56,11 +59,18 @@ int main( int argc, const char* argv[] ) {
             //} catch( const std::exception &ch ) {
             //std::cout << "Real exception: " << typeid(ch).name() << ", " << ch.what() << std::endl;
         } catch( const std::string& ch ) {
-            std::cout << "Exception: " << ch << std::endl;
+            logger::error( "Exception: ", ch );
         } catch( char const* ch ) {
-            std::cout << "Exception: " << ch << std::endl;
+            logger::error( "Exception: ", ch );
         }
     }
 
     return -1;
+
+} catch( std::exception& e ) {
+    logger::fatalf( "Fatal Error: %s!\n", e.what() );
+    return -1;
+} catch( ... ) {
+    logger::fatal( "Fatal Error: Unknown Exception!\n" );
+    return -1;
 }