X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fapps%2Fsigner.cpp;h=2b6798c935aa2f15893c5c059ed5135d640797e3;hb=284fe577c65bbdda151d80e2261617a4c7119ed5;hp=baa45c72fef8865e170326b7ab5b3f1a755db8c0;hpb=5b632376dc58b58dcfd8c73ece4b6ea698a8f61f;p=cassiopeia.git diff --git a/src/apps/signer.cpp b/src/apps/signer.cpp index baa45c7..2b6798c 100644 --- a/src/apps/signer.cpp +++ b/src/apps/signer.cpp @@ -11,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" @@ -35,40 +36,42 @@ int main( int argc, const char* argv[] ) try { #endif if( parseConfig( path ) != 0 ) { + logger::fatal( "Could not parse configuration file." ); return -1; } std::shared_ptr 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; } std::shared_ptr conn = openSerial( serialPath ); std::shared_ptr slip1( BIO_new( toBio() ), BIO_free ); - static_cast( slip1->ptr )->setTarget( std::shared_ptr( new OpensslBIOWrapper( conn ) ) ); + static_cast( slip1->ptr )->setTarget( std::shared_ptr( new OpensslBIOWrapper( conn ) ), true ); DefaultRecordHandler* dh = new DefaultRecordHandler( std::shared_ptr( new SimpleOpensslSigner( ) ), slip1 ); + logger::note( "Entering mainloop" ); while( true ) { try { dh->handle(); //} 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) { - std::cerr << "Fatal Error: " << e.what() << "!\n"; +} catch( std::exception& e ) { + logger::fatalf( "Fatal Error: %s!\n", e.what() ); return -1; -} catch(...) { - std::cerr << "Fatal Error: Unknown Exception!\n"; +} catch( ... ) { + logger::fatal( "Fatal Error: Unknown Exception!\n" ); return -1; }