1
0
mirror of https://github.com/GOSTSec/gostcoin synced 2025-03-13 05:41:11 +00:00

write SAM messages to sam.log

This commit is contained in:
orignal 2017-04-06 21:09:02 -04:00
parent d0db9c289f
commit 9871500bc2
2 changed files with 18 additions and 8 deletions

View File

@ -586,7 +586,7 @@ std::ostream& StreamSession::getLogStream ()
void StreamSession::SetLogFile (const std::string& filename)
{
logStream = std::make_shared<std::ofstream> (filename, std::ofstream::out | std::ofstream::app);
logStream = std::make_shared<std::ofstream> (filename, std::ofstream::out | std::ofstream::trunc);
}
void StreamSession::CloseLogFile ()

View File

@ -14,6 +14,7 @@ class StreamSessionAdapter::SessionHolder
{
public:
explicit SessionHolder(std::shared_ptr<SAM::StreamSession> session);
~SessionHolder();
const SAM::StreamSession& getSession() const;
SAM::StreamSession& getSession();
@ -28,7 +29,12 @@ private:
StreamSessionAdapter::SessionHolder::SessionHolder(std::shared_ptr<SAM::StreamSession> 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<SAM::StreamSession>(
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<SAM::StreamSession>(nickname, SAMHost, SAMPort, myDestination, i2pOptions, minVer, maxVer);
sessionHolder_ = std::make_shared<SessionHolder>(s);
std::cout << "SAM session created" << std::endl;
}
StreamSessionAdapter::~StreamSessionAdapter()
{}
{
SAM::StreamSession::CloseLogFile ();
}
SAM::SOCKET StreamSessionAdapter::accept(bool silent)
{