From b8c1b47e32215cfa9f0483144ee643867ffc67c7 Mon Sep 17 00:00:00 2001 From: claiff Date: Fri, 23 Sep 2022 16:16:56 +0300 Subject: add phosphor logger --- src/file/mail.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/file/mail.cpp') diff --git a/src/file/mail.cpp b/src/file/mail.cpp index cf5fe26..2a2231b 100644 --- a/src/file/mail.cpp +++ b/src/file/mail.cpp @@ -13,10 +13,12 @@ namespace smtp::file manage::MailsSet Mail::Read() const { + static const std::string METHOD_NAME = "Read mails"; + std::ifstream mail_file{ mPathFile, std::fstream::in }; if ( !mail_file.is_open() ) { - manage::Logger::LogError( "Unable to open file to read " + mPathFile ); + logger::LoggerSet::GetInstance()->LogError( METHOD_NAME, "Unable to open file to read " + mPathFile ); return {}; } std::string line{}; @@ -35,10 +37,12 @@ namespace smtp::file bool Mail::Write( manage::MailsSet const& data ) const { + static const std::string METHOD_NAME = "Write mails"; + std::ofstream mail_file{ mPathFile, std::fstream::out | std::fstream::trunc }; if ( !mail_file.is_open() ) { - manage::Logger::LogError( "Unable to open file to write " + mPathFile ); + logger::LoggerSet::GetInstance()->LogError( METHOD_NAME, "Unable to open file to write " + mPathFile ); return false; } for( const auto& mail : data ) -- cgit v1.2.3