Browse Source

write SAM messages to sam.log

pull/5/head
orignal 7 years ago
parent
commit
9871500bc2
  1. 2
      i2psam/i2psam.cpp
  2. 24
      src/i2p.cpp

2
i2psam/i2psam.cpp

@ -586,7 +586,7 @@ std::ostream& StreamSession::getLogStream () @@ -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 ()

24
src/i2p.cpp

@ -14,6 +14,7 @@ class StreamSessionAdapter::SessionHolder @@ -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: @@ -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( @@ -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)
{

Loading…
Cancel
Save