|
reSIProcate/rutil
9694
|
#include <Log.hxx>

Public Member Functions | |
| ThreadData (LocalLoggerId id, Type type=Cout, Level level=Info, const char *logFileName=NULL, ExternalLogger *pExternalLogger=NULL) | |
| ~ThreadData () | |
| void | set (Type type=Cout, Level level=Info, const char *logFileName=NULL, ExternalLogger *pExternalLogger=NULL) |
| LocalLoggerId | id () const |
| unsigned int | maxLineCount () |
| unsigned int | maxByteCount () |
| std::ostream & | Instance (unsigned int bytesToWrite) |
| Return logger stream instance, creating it if needed. | |
| void | reset () |
| Frees logger stream. | |
Public Attributes | |
| volatile Level | mLevel |
| volatile unsigned int | mMaxLineCount |
| volatile unsigned int | mMaxByteCount |
| ExternalLogger * | mExternalLogger |
Protected Attributes | |
| const LocalLoggerId | mId |
| Type | mType |
| Data | mLogFileName |
| std::ostream * | mLogger |
| unsigned int | mLineCount |
Friends | |
| class | Guard |
| resip::Log::ThreadData::ThreadData | ( | LocalLoggerId | id, |
| Type | type = Cout, |
||
| Level | level = Info, |
||
| const char * | logFileName = NULL, |
||
| ExternalLogger * | pExternalLogger = NULL |
||
| ) | [inline] |
Definition at line 269 of file Log.hxx.
References mLogFileName.
: mLevel(level), mMaxLineCount(0), mMaxByteCount(0), mExternalLogger(pExternalLogger), mId(id), mType(type), mLogger(NULL), mLineCount(0) { if (logFileName) { mLogFileName = logFileName; } }
| resip::Log::ThreadData::~ThreadData | ( | ) | [inline] |
| LocalLoggerId resip::Log::ThreadData::id | ( | ) | const [inline] |
Definition at line 302 of file Log.hxx.
References mId.
Referenced by resip::Log::id(), and resip::Log::setThreadLocalLogger().
{return mId;}
| std::ostream & Log::ThreadData::Instance | ( | unsigned int | bytesToWrite | ) |
Return logger stream instance, creating it if needed.
Definition at line 775 of file Log.cxx.
References resip::Data::c_str(), resip::Log::Cerr, resip::Log::Cout, resip::Log::File, and resip::Log::Syslog.
{
// std::cerr << "Log::ThreadData::Instance() id=" << mId << " type=" << mType << std::endl;
switch (mType)
{
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 (mLogger == 0 ||
(maxLineCount() && mLineCount >= maxLineCount()) ||
(maxByteCount() && ((unsigned int)mLogger->tellp()+bytesToWrite) >= maxByteCount()))
{
std::cerr << "Creating a logger for file \"" << mLogFileName.c_str() << "\"" << std::endl;
Data logFileName(mLogFileName != "" ? mLogFileName : "resiprocate.log");
if (mLogger)
{
Data oldLogFileName(logFileName + ".old");
delete mLogger;
// Keep one backup file: Delete .old file, Rename log file to .old
// Could be expanded in the future to keep X backup log files
remove(oldLogFileName.c_str());
rename(logFileName.c_str(), oldLogFileName.c_str());
}
// Append to log if we have a line count or byte count limit - otherwise truncate
mLogger = new std::ofstream(logFileName.c_str(), std::ios_base::out | ((maxLineCount() > 0 || maxByteCount() > 0) ? std::ios_base::app : std::ios_base::trunc));
mLineCount = 0;
}
mLineCount++;
return *mLogger;
default:
assert(0);
return std::cout;
}
}

| unsigned int resip::Log::ThreadData::maxByteCount | ( | ) | [inline] |
Definition at line 304 of file Log.hxx.
References resip::Log::MaxByteCount, and mMaxByteCount.
{ return mMaxByteCount ? mMaxByteCount : MaxByteCount; } // return local max, if not set use global max
| unsigned int resip::Log::ThreadData::maxLineCount | ( | ) | [inline] |
Definition at line 303 of file Log.hxx.
References resip::Log::MaxLineCount, and mMaxLineCount.
{ return mMaxLineCount ? mMaxLineCount : MaxLineCount; } // return local max, if not set use global max
| void Log::ThreadData::reset | ( | ) |
| void resip::Log::ThreadData::set | ( | Type | type = Cout, |
| Level | level = Info, |
||
| const char * | logFileName = NULL, |
||
| ExternalLogger * | pExternalLogger = NULL |
||
| ) | [inline] |
Definition at line 288 of file Log.hxx.
References resip::Log::level(), mExternalLogger, mLevel, mLogFileName, and mType.
{
mType = type;
mLevel = level;
if (logFileName)
{
mLogFileName = logFileName;
}
mExternalLogger = pExternalLogger;
}

Definition at line 312 of file Log.hxx.
Referenced by resip::Log::getExternal(), and set().
const LocalLoggerId resip::Log::ThreadData::mId [protected] |
| volatile Level resip::Log::ThreadData::mLevel |
Definition at line 309 of file Log.hxx.
Referenced by resip::Log::level(), set(), and resip::Log::setLevel().
unsigned int resip::Log::ThreadData::mLineCount [protected] |
Data resip::Log::ThreadData::mLogFileName [protected] |
Definition at line 318 of file Log.hxx.
Referenced by set(), and ThreadData().
std::ostream* resip::Log::ThreadData::mLogger [protected] |
| volatile unsigned int resip::Log::ThreadData::mMaxByteCount |
Definition at line 311 of file Log.hxx.
Referenced by maxByteCount(), and resip::Log::setMaxByteCount().
| volatile unsigned int resip::Log::ThreadData::mMaxLineCount |
Definition at line 310 of file Log.hxx.
Referenced by maxLineCount(), and resip::Log::setMaxLineCount().
Type resip::Log::ThreadData::mType [protected] |
Definition at line 317 of file Log.hxx.
Referenced by set(), and resip::Log::Guard::~Guard().
1.7.5.1