diff --git a/i2psam/i2psam.cpp b/i2psam/i2psam.cpp index c5efa20..52b2ff2 100644 --- a/i2psam/i2psam.cpp +++ b/i2psam/i2psam.cpp @@ -586,7 +586,7 @@ std::ostream& StreamSession::getLogStream () void StreamSession::SetLogFile (const std::string& filename) { - logStream = std::make_shared (filename, std::ofstream::out | std::ofstream::app); + logStream = std::make_shared (filename, std::ofstream::out | std::ofstream::trunc); } void StreamSession::CloseLogFile () diff --git a/src/i2p.cpp b/src/i2p.cpp index cc5af80..88c00ed 100644 --- a/src/i2p.cpp +++ b/src/i2p.cpp @@ -14,6 +14,7 @@ class StreamSessionAdapter::SessionHolder { public: explicit SessionHolder(std::shared_ptr session); + ~SessionHolder(); const SAM::StreamSession& getSession() const; SAM::StreamSession& getSession(); @@ -28,7 +29,12 @@ private: StreamSessionAdapter::SessionHolder::SessionHolder(std::shared_ptr session) : session_(session) -{} +{ +} + +StreamSessionAdapter::SessionHolder::~SessionHolder() +{ +} const SAM::StreamSession& StreamSessionAdapter::SessionHolder::getSession() const { @@ -76,14 +82,18 @@ StreamSessionAdapter::StreamSessionAdapter( const std::string& i2pOptions /*= SAM_DEFAULT_I2P_OPTIONS*/, const std::string& minVer /*= SAM_DEFAULT_MIN_VER*/, const std::string& maxVer /*= SAM_DEFAULT_MAX_VER*/) - : sessionHolder_( - new SessionHolder( - std::auto_ptr( - new SAM::StreamSession(nickname, SAMHost, SAMPort, myDestination, i2pOptions, minVer, maxVer)))) -{} +{ + SAM::StreamSession::SetLogFile ((GetDataDir() / "sam.log").string ()); + std::cout << "Creating SAM session ..." << std::endl; + auto s = std::make_shared(nickname, SAMHost, SAMPort, myDestination, i2pOptions, minVer, maxVer); + sessionHolder_ = std::make_shared(s); + std::cout << "SAM session created" << std::endl; +} StreamSessionAdapter::~StreamSessionAdapter() -{} +{ + SAM::StreamSession::CloseLogFile (); +} SAM::SOCKET StreamSessionAdapter::accept(bool silent) {