< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate-users] rotate resip log automatically


Thanks hongsion ? I’ll will take a look at this as soon as I get some cycles.

 

Scott

 

From: hongsion [mailto:hongsion@xxxxxxxxx]
Sent: Thursday, April 17, 2008 5:38 AM
To: Scott Godin; resiprocate-users
Subject: rotate resip log automatically

 

hi scott,

I just add following code, implement log automatically rotate. i think this is useful when using for a sip proxy server.

 

std::ostream* GenericLogImpl::mLogger=0;

unsigned int GenericLogImpl::mLineCount=0;

unsigned int GenericLogImpl::MaxLineCount = 50000; // no limit by default    50000 about 5M size

 

std::ostream&

GenericLogImpl::Instance()

{

   switch (Log::_type)

   {

      case Log::Syslog:

         if (mLogger == 0)

         {

            std::cerr << "Creating a syslog stream" << std::endl;

            mLogger = new SysLogStream;

         }

         return *mLogger;

      case Log::Cerr:

         return std::cerr;

      case Log::Cout:

         return std::cout;

      case Log::File:

   

    if(MaxLineCount && mLineCount > MaxLineCount)                //<<<<<<<changed here

reset();

 

         if (mLogger == 0)

         {

              std::cerr << "Creating a file logger" << std::endl;

 

 if(Log::mLogFileName.empty())

Log::mLogFileName = "resiprocate.log";

 

               mLogger = new std::ofstream(mLogFileName.c_str(), std::ios_base::out | std::ios_base::trunc);

               mLineCount = 0;

         }

 

         mLineCount++;

         return *mLogger;

 

      default:

         assert(0);

         return std::cout;

   }

}

void 

GenericLogImpl::reset()

{

   delete mLogger;

   mLogger = 0;

 

std::string logName = Log::mLogFileName.c_str();

std::string newLogName = logName;

std::string::size_type idx = logName.find_last_of(".");

 

if(idx != std::string::npos)

{

newLogName = logName.substr(0,idx);

}

else

newLogName = logName;

 

char timeStr[32];

time_t now = time(NULL);

strftime(timeStr, sizeof(timeStr), "%Y%m%d%H%M%S", localtime(&now));

newLogName += timeStr;

newLogName += ".txt";

 

#ifdef _WIN32

MoveFile(logName.c_str(), newLogName.c_str());

#else

///<<<<< need to add by others who know linux or unix

#endif

}

 

 

2008-04-17


hongsion


发件人: Scott Godin

发送时间: 2008-04-10  22:13:27

收件人: D. S.; resiprocate-users@xxxxxxxxxxxxxxx

抄送:

主题: Re: [reSIProcate-users] Add RTP To Repository?

I would recommend looking at the sipX media stack ? www.sipfoundry.org

http://sipx-wiki.calivia.com/index.php/SipXtapi_User_Agent_Projects

http://sipx-wiki.calivia.com/index.php/SipXmediaLib

 

Scott

 

From: resiprocate-users-bounces@xxxxxxxxxxxxxxx [mailto:resiprocate-users-bounces@xxxxxxxxxxxxxxx] On Behalf Of D. S.
Sent: Wednesday, April 09, 2008 1:36 PM
To: resiprocate-users@xxxxxxxxxxxxxxx
Subject: [reSIProcate-users] Add RTP To Repository?

 

It appears that the Vovida web site is non-functional and there does not seem to be a Sourceforge project to host its source code.

Would you consider adding the Vovida RTP source code to the ReSiprocate repository for reference, not maintenance?

This would be in the spirit of the consistent Vovida license.

Or, do you know of any other RTP stack that is equally unencumbered and tested by many?