|
reSIProcate/rutil
9694
|
Singleton that handles logging calls. More...
#include <Log.hxx>

Classes | |
| class | Guard |
| Implementation for logging macros. More... | |
| class | LocalLoggerMap |
| Thread Local logger settings storage. More... | |
| class | ThreadData |
| class | ThreadSetting |
Public Types | |
| enum | Type { Cout = 0, Syslog, File, Cerr, VSDebugWindow, OnlyExternal, OnlyExternalNoHeaders } |
| enum | Level { None = -1, Crit = LOG_CRIT, Err, Warning = LOG_WARNING, Info = LOG_INFO, Debug = LOG_DEBUG, Stack = 8, StdErr = 9, Bogus = 666 } |
| typedef int | LocalLoggerId |
| Thread Local logger ID type. | |
Static Public Member Functions | |
| static EncodeStream & | tags (Log::Level level, const Subsystem &subsystem, const char *file, int line, EncodeStream &strm) |
| output the loglevel, hostname, appname, pid, tid, subsystem | |
| static Data & | timestamp (Data &result) |
| static Data | timestamp () |
| static ExternalLogger * | getExternal () |
| static Data | getAppName () |
| static void | initialize (Type type, Level level, const Data &appName, const char *logFileName=0, ExternalLogger *externalLogger=0) |
| static void | initialize (const Data &type, const Data &level, const Data &appName, const char *logFileName=0, ExternalLogger *externalLogger=0) |
| static void | initialize (const char *type, const char *level, const char *appName, const char *logFileName=0, ExternalLogger *externalLogger=0) |
| static void | initialize (Type type, Level level, const Data &appName, ExternalLogger &logger) |
| static void | setLevel (Level level) |
| Set logging level for current thread. | |
| static void | setLevel (Level level, Subsystem &s) |
| Set logging level for given subsystem. | |
| static void | setLevel (Level level, LocalLoggerId loggerId) |
| Set logging level for given local logger. | |
| static Level | level () |
| Return logging level for current thread. | |
| static Level | level (LocalLoggerId loggerId) |
| Return logging level for given local logger. | |
| static LocalLoggerId | id () |
| static void | setMaxLineCount (unsigned int maxLineCount) |
| static void | setMaxLineCount (unsigned int maxLineCount, LocalLoggerId loggerId) |
| static void | setMaxByteCount (unsigned int maxByteCount) |
| static void | setMaxByteCount (unsigned int maxByteCount, LocalLoggerId loggerId) |
| static Level | toLevel (const Data &l) |
| static Type | toType (const Data &t) |
| static Data | toString (Level l) |
| static void | setServiceLevel (int service, Level l) |
| DEPRECATED! Left for backward compatibility - use localLoggers instead. | |
| static Level | getServiceLevel (int service) |
| static const ThreadSetting * | getThreadSetting () |
| DEPRECATED! Left for backward compatibility - use localLoggers instead. | |
| static void | setThreadSetting (ThreadSetting info) |
| static void | setThreadSetting (int serv, Level l) |
| static void | setThreadSetting (int serv) |
| static LocalLoggerId | localLoggerCreate (Type type, Level level, const char *logFileName=NULL, ExternalLogger *externalLogger=NULL) |
| Create new logger instance and return its ID (zero on error) | |
| static int | localLoggerReinitialize (LocalLoggerId loggerId, Type type, Level level, const char *logFileName=NULL, ExternalLogger *externalLogger=NULL) |
| Reinitialize all new setting for a local logger instance. | |
| static int | localLoggerRemove (LocalLoggerId loggerId) |
| Destroy existing logger instance. | |
| static int | setThreadLocalLogger (LocalLoggerId loggerId) |
| Set logger instance with given ID as a thread local logger. | |
| static std::ostream & | Instance (unsigned int bytesToWrite) |
| static bool | isLogging (Log::Level level, const Subsystem &) |
| static void | OutputToWin32DebugWindow (const Data &result) |
| static void | reset () |
| Frees logger stream. | |
Static Public Attributes | |
| static unsigned int | MaxLineCount = 0 |
| static unsigned int | MaxByteCount = 0 |
Protected Member Functions | |
| friend | void::freeLocalLogger (void *pThreadData) |
Static Protected Member Functions | |
| static ThreadData & | getLoggerData () |
Static Protected Attributes | |
| static Mutex | _mutex |
| static volatile short | touchCount = 0 |
| static const Data | delim |
| static ThreadData | mDefaultLoggerData |
| Default logger settings. | |
| static Data | mAppName |
| static Data | mHostname |
| static pid_t | mPid = 0 |
| static const char | mDescriptions [][32] = {"NONE", "EMERG", "ALERT", "CRIT", "ERR", "WARNING", "NOTICE", "INFO", "DEBUG", "STACK", "CERR", ""} |
| static LocalLoggerMap | mLocalLoggerMap |
| static ThreadIf::TlsKey * | mLocalLoggerKey |
| static HashMap< ThreadIf::Id, std::pair< ThreadSetting, bool > > | mThreadToLevel |
| DEPRECATED! Left for backward compatibility - use localLoggers instead. | |
| static HashMap< int, std::set < ThreadIf::Id > > | mServiceToThreads |
| static ThreadIf::TlsKey * | mLevelKey |
| static HashMap< int, Level > | mServiceToLevel |
| DEPRECATED! Left for backward compatibility - use localLoggers instead. | |
Friends | |
| class | LogStaticInitializer |
Singleton that handles logging calls.
| typedef int resip::Log::LocalLoggerId |
| enum resip::Log::Level |
Definition at line 68 of file Log.hxx.
{
None = -1,
#ifdef WIN32
Crit = 2,
Err = 3,
Warning = 4,
Info = 6,
Debug = 7,
#else
Crit = LOG_CRIT,
// #ifdef ERR // ncurses defines a macro called ERR
// SIP2_ERR = LOG_ERR,
// #else
// ERR = LOG_ERR,
// #endif
Err,
Warning = LOG_WARNING,
Info = LOG_INFO,
Debug = LOG_DEBUG,
#endif
Stack = 8,
StdErr = 9,
Bogus = 666
};
| enum resip::Log::Type |
| Cout | |
| Syslog | |
| File | |
| Cerr | |
| VSDebugWindow |
Use only for Visual Studio Debug Window logging - WIN32 must be defined. |
| OnlyExternal |
log messages are only written to external logger |
| OnlyExternalNoHeaders |
same as OnlyExternal, only the messageWithHeaders param of the ExternalLogger will be empty. This parameter usually contains a pre-formatted log entry. |
Definition at line 56 of file Log.hxx.
{
Cout = 0,
Syslog,
File,
Cerr,
VSDebugWindow,
OnlyExternal,
OnlyExternalNoHeaders
};
| static Data resip::Log::getAppName | ( | ) | [inline, static] |
Definition at line 161 of file Log.hxx.
References mAppName.
Referenced by resip::Log::Guard::~Guard().
{
return mAppName;
}
| static ExternalLogger* resip::Log::getExternal | ( | ) | [inline, static] |
Definition at line 157 of file Log.hxx.
References getLoggerData(), and resip::Log::ThreadData::mExternalLogger.
Referenced by resip::Log::Guard::~Guard().
{
return getLoggerData().mExternalLogger;
}

| static ThreadData& resip::Log::getLoggerData | ( | ) | [inline, static, protected] |
Definition at line 333 of file Log.hxx.
References mDefaultLoggerData, mLocalLoggerKey, and resip::ThreadIf::tlsGetValue().
Referenced by getExternal(), resip::Log::Guard::Guard(), id(), isLogging(), level(), and resip::Log::Guard::~Guard().
{
ThreadData* pData = static_cast<ThreadData*>(ThreadIf::tlsGetValue(*Log::mLocalLoggerKey));
return pData?*pData:mDefaultLoggerData;
}

| Log::Level Log::getServiceLevel | ( | int | service | ) | [static] |
dcm! -- should perhaps throw an exception here, instead of setting a
Definition at line 446 of file Log.cxx.
References mServiceToLevel.
{
Lock lock(_mutex);
HashMap<int, Level>::iterator res = Log::mServiceToLevel.find(service);
if(res == Log::mServiceToLevel.end())
{
//default level of LOG_ERROR, but nobody uses this yet
Log::mServiceToLevel[service] = Err;
return Err;
}
return res->second;
}
| const Log::ThreadSetting * Log::getThreadSetting | ( | ) | [static] |
DEPRECATED! Left for backward compatibility - use localLoggers instead.
Definition at line 461 of file Log.cxx.
References resip::Log::ThreadSetting::mLevel, mLevelKey, mThreadToLevel, resip::ThreadIf::selfId(), resip::ThreadIf::tlsGetValue(), and touchCount.
{
#ifndef LOG_ENABLE_THREAD_SETTING
return 0;
#else
ThreadSetting* setting = static_cast<ThreadSetting*>(ThreadIf::tlsGetValue(*Log::mLevelKey));
if (setting == 0)
{
return 0;
}
if (Log::touchCount > 0)
{
Lock lock(_mutex);
ThreadIf::Id thread = ThreadIf::selfId();
HashMap<ThreadIf::Id, pair<ThreadSetting, bool> >::iterator res = Log::mThreadToLevel.find(thread);
assert(res != Log::mThreadToLevel.end());
if (res->second.second)
{
setting->mLevel = res->second.first.mLevel;
res->second.second = false;
touchCount--;
// cerr << "**Log::getThreadSetting:touchCount: " << Log::touchCount << "**" << endl;
//cerr << "touchcount decremented" << endl;
}
}
return setting;
#endif
}

| static LocalLoggerId resip::Log::id | ( | ) | [inline, static] |
Definition at line 200 of file Log.hxx.
References _mutex, getLoggerData(), and resip::Log::ThreadData::id().
{ Lock lock(_mutex); return getLoggerData().id(); }

| void Log::initialize | ( | Type | type, |
| Level | level, | ||
| const Data & | appName, | ||
| const char * | logFileName = 0, |
||
| ExternalLogger * | externalLogger = 0 |
||
| ) | [static] |
Definition at line 131 of file Log.cxx.
References resip::ParseBuffer::position(), resip::ParseBuffer::skipBackToChar(), and resip::ParseBuffer::skipToEnd().
Referenced by initialize(), TestData::main(), main(), and testThreadLocalLoggers().
{
Lock lock(_mutex);
mDefaultLoggerData.reset();
mDefaultLoggerData.set(type, level, logFileName, externalLogger);
ParseBuffer pb(appName);
pb.skipToEnd();
#ifdef _WIN32
pb.skipBackToChar('\\');
#else
pb.skipBackToChar('/');
#endif
mAppName = pb.position();
char buffer[1024];
gethostname(buffer, sizeof(buffer));
mHostname = buffer;
#ifdef WIN32
mPid = (int)GetCurrentProcess();
#else
mPid = getpid();
#endif
}

| void Log::initialize | ( | const Data & | type, |
| const Data & | level, | ||
| const Data & | appName, | ||
| const char * | logFileName = 0, |
||
| ExternalLogger * | externalLogger = 0 |
||
| ) | [static] |
Definition at line 115 of file Log.cxx.
References Cerr, Cout, File, Info, initialize(), resip::isEqualNoCase(), and Syslog.
{
Type type = Log::Cout;
if (isEqualNoCase(typed, "cout")) type = Log::Cout;
else if (isEqualNoCase(typed, "cerr")) type = Log::Cerr;
else if (isEqualNoCase(typed, "file")) type = Log::File;
else type = Log::Syslog;
Level level = Log::Info;
level = toLevel(leveld);
Log::initialize(type, level, appName, logFileName, externalLogger);
}

| void Log::initialize | ( | const char * | type, |
| const char * | level, | ||
| const char * | appName, | ||
| const char * | logFileName = 0, |
||
| ExternalLogger * | externalLogger = 0 |
||
| ) | [static] |
Definition at line 109 of file Log.cxx.
References initialize().
{
Log::initialize(Data(typed), Data(leveld), Data(appName), logFileName, externalLogger);
}

| void Log::initialize | ( | Type | type, |
| Level | level, | ||
| const Data & | appName, | ||
| ExternalLogger & | logger | ||
| ) | [static] |
Definition at line 160 of file Log.cxx.
{
initialize(type, level, appName, 0, &logger);
}
| std::ostream & Log::Instance | ( | unsigned int | bytesToWrite | ) | [static] |
Definition at line 587 of file Log.cxx.
Referenced by resip::Log::Guard::~Guard().
{
return getLoggerData().Instance(bytesToWrite);
}
| bool Log::isLogging | ( | Log::Level | level, |
| const Subsystem & | sub | ||
| ) | [static] |
Definition at line 599 of file Log.cxx.
References resip::Subsystem::getLevel(), getLoggerData(), and None.
Referenced by genericLogCheckLevel().
{
if (sub.getLevel() != Log::None)
{
return level <= sub.getLevel();
}
else
{
return (level <= Log::getLoggerData().mLevel);
}
}

| static Level resip::Log::level | ( | ) | [inline, static] |
Return logging level for current thread.
If thread has no local logger attached, then return global logging level.
Definition at line 197 of file Log.hxx.
References _mutex, getLoggerData(), and resip::Log::ThreadData::mLevel.
Referenced by resip::Log::ThreadData::set().
{ Lock lock(_mutex); return getLoggerData().mLevel; }

| Log::Level Log::level | ( | Log::LocalLoggerId | loggerId | ) | [static] |
Return logging level for given local logger.
Use 0 to set global logging level.
Definition at line 206 of file Log.cxx.
References resip::Log::ThreadData::mLevel.
{
Level level;
ThreadData *pData;
if (loggerId && (pData = mLocalLoggerMap.getData(loggerId)))
{
// Local logger found. Set logging level.
level = pData->mLevel;
// We don't need local logger instance anymore.
mLocalLoggerMap.decreaseUseCount(loggerId);
pData = NULL;
}
else
{
Lock lock(_mutex);
level = mDefaultLoggerData.mLevel;
}
return level;
}
| Log::LocalLoggerId Log::localLoggerCreate | ( | Log::Type | type, |
| Log::Level | level, | ||
| const char * | logFileName = NULL, |
||
| ExternalLogger * | externalLogger = NULL |
||
| ) | [static] |
Create new logger instance and return its ID (zero on error)
Definition at line 546 of file Log.cxx.
Referenced by testThreadLocalLoggers().
{
return mLocalLoggerMap.create(type, level, logFileName, externalLogger);
}
| int Log::localLoggerReinitialize | ( | Log::LocalLoggerId | loggerId, |
| Log::Type | type, | ||
| Log::Level | level, | ||
| const char * | logFileName = NULL, |
||
| ExternalLogger * | externalLogger = NULL |
||
| ) | [static] |
Reinitialize all new setting for a local logger instance.
| 0 | on success |
| 1 | if logger does not exist |
Definition at line 554 of file Log.cxx.
{
return mLocalLoggerMap.reinitialize(loggerId, type, level, logFileName, externalLogger);
}
| int Log::localLoggerRemove | ( | Log::LocalLoggerId | loggerId | ) | [static] |
Destroy existing logger instance.
| 0 | on success |
| 1 | if logger does not exist |
| 2 | if logger is still in use |
| >2 | on other failures |
Definition at line 563 of file Log.cxx.
Referenced by testThreadLocalLoggers().
{
return mLocalLoggerMap.remove(loggerId);
}
| void Log::OutputToWin32DebugWindow | ( | const Data & | result | ) | [static] |
Definition at line 612 of file Log.cxx.
References resip::Data::c_str(), resip::FreeWString(), and resip::ToWString().
Referenced by resip::Log::Guard::~Guard().
{
#ifdef WIN32
const char *text = result.c_str();
#ifdef UNDER_CE
LPWSTR lpwstrText = resip::ToWString(text);
OutputDebugStringW(lpwstrText);
FreeWString(lpwstrText);
#else
OutputDebugStringA(text);
#endif
#endif
}

| void Log::reset | ( | ) | [static] |
| void Log::setLevel | ( | Level | level | ) | [static] |
| void Log::setLevel | ( | Level | level, |
| Log::LocalLoggerId | loggerId | ||
| ) | [static] |
Set logging level for given local logger.
Use 0 to set global logging level.
Definition at line 183 of file Log.cxx.
References resip::Log::ThreadData::mLevel.
{
if (loggerId)
{
ThreadData *pData = mLocalLoggerMap.getData(loggerId);
if (pData)
{
// Local logger found. Set logging level.
pData->mLevel = level;
// We don't need local logger instance anymore.
mLocalLoggerMap.decreaseUseCount(loggerId);
pData = NULL;
}
}
else
{
Lock lock(_mutex);
mDefaultLoggerData.mLevel = level;
}
}
| void Log::setMaxByteCount | ( | unsigned int | maxByteCount | ) | [static] |
Definition at line 258 of file Log.cxx.
{
Lock lock(_mutex);
getLoggerData().mMaxByteCount = maxByteCount;
}
| void Log::setMaxByteCount | ( | unsigned int | maxByteCount, |
| Log::LocalLoggerId | loggerId | ||
| ) | [static] |
Definition at line 265 of file Log.cxx.
References resip::Log::ThreadData::mMaxByteCount.
{
if (loggerId)
{
ThreadData *pData = mLocalLoggerMap.getData(loggerId);
if (pData)
{
// Local logger found. Set logging level.
pData->mMaxByteCount = maxByteCount;
// We don't need local logger instance anymore.
mLocalLoggerMap.decreaseUseCount(loggerId);
pData = NULL;
}
}
else
{
Lock lock(_mutex);
mDefaultLoggerData.mMaxByteCount = maxByteCount;
}
}
| void Log::setMaxLineCount | ( | unsigned int | maxLineCount | ) | [static] |
Definition at line 228 of file Log.cxx.
{
Lock lock(_mutex);
getLoggerData().mMaxLineCount = maxLineCount;
}
| void Log::setMaxLineCount | ( | unsigned int | maxLineCount, |
| Log::LocalLoggerId | loggerId | ||
| ) | [static] |
Definition at line 235 of file Log.cxx.
References resip::Log::ThreadData::mMaxLineCount.
{
if (loggerId)
{
ThreadData *pData = mLocalLoggerMap.getData(loggerId);
if (pData)
{
// Local logger found. Set logging level.
pData->mMaxLineCount = maxLineCount;
// We don't need local logger instance anymore.
mLocalLoggerMap.decreaseUseCount(loggerId);
pData = NULL;
}
}
else
{
Lock lock(_mutex);
mDefaultLoggerData.mMaxLineCount = maxLineCount;
}
}
| void Log::setServiceLevel | ( | int | service, |
| Level | l | ||
| ) | [static] |
DEPRECATED! Left for backward compatibility - use localLoggers instead.
Definition at line 528 of file Log.cxx.
References mServiceToLevel, mServiceToThreads, mThreadToLevel, and touchCount.
Referenced by main().
{
Lock lock(_mutex);
Log::mServiceToLevel[service] = l;
#ifndef LOG_ENABLE_THREAD_SETTING
assert(0);
#else
set<ThreadIf::Id>& threads = Log::mServiceToThreads[service];
for (set<ThreadIf::Id>::iterator i = threads.begin(); i != threads.end(); i++)
{
Log::mThreadToLevel[*i].first.mLevel = l;
Log::mThreadToLevel[*i].second = true;
}
Log::touchCount += (short)threads.size();
#endif
// cerr << "**Log::setServiceLevel:touchCount: " << Log::touchCount << "**" << endl;
}
| int Log::setThreadLocalLogger | ( | Log::LocalLoggerId | loggerId | ) | [static] |
Set logger instance with given ID as a thread local logger.
Pass zero loggerId to remove thread local logger.
| 0 | on success |
| 1 | if logger does not exist |
| >1 | on other failures |
Definition at line 568 of file Log.cxx.
References resip::Log::ThreadData::id(), mLocalLoggerKey, resip::ThreadIf::tlsGetValue(), and resip::ThreadIf::tlsSetValue().
Referenced by LogThread::thread().
{
ThreadData* pData = static_cast<ThreadData*>(ThreadIf::tlsGetValue(*Log::mLocalLoggerKey));
if (pData)
{
// There was some local logger installed. Decrease its use count before we
// continue.
mLocalLoggerMap.decreaseUseCount(pData->id());
pData = NULL;
}
if (loggerId)
{
pData = mLocalLoggerMap.getData(loggerId);
}
ThreadIf::tlsSetValue(*mLocalLoggerKey, (void *) pData);
return (loggerId == 0) || (pData != NULL)?0:1;
}

| void Log::setThreadSetting | ( | ThreadSetting | info | ) | [static] |
Definition at line 504 of file Log.cxx.
References resip::Log::ThreadSetting::mService, mServiceToThreads, mThreadToLevel, resip::ThreadIf::selfId(), and resip::ThreadIf::tlsSetValue().
Referenced by setThreadSetting(), and LogThread::thread().
{
#ifndef LOG_ENABLE_THREAD_SETTING
assert(0);
#else
//cerr << "Log::setThreadSetting: " << "service: " << info.service << " level " << toString(info.level) << " for " << pthread_self() << endl;
ThreadIf::Id thread = ThreadIf::selfId();
ThreadIf::tlsSetValue(*mLevelKey, (void *) new ThreadSetting(info));
Lock lock(_mutex);
if (Log::mThreadToLevel.find(thread) != Log::mThreadToLevel.end())
{
if (Log::mThreadToLevel[thread].second == true)
{
touchCount--;
}
}
Log::mThreadToLevel[thread].first = info;
Log::mThreadToLevel[thread].second = false;
Log::mServiceToThreads[info.mService].insert(thread);
#endif
}

| void Log::setThreadSetting | ( | int | serv, |
| Log::Level | l | ||
| ) | [static] |
Definition at line 498 of file Log.cxx.
References setThreadSetting().
{
Log::setThreadSetting(ThreadSetting(serv, l));
}

| void Log::setThreadSetting | ( | int | serv | ) | [static] |
Definition at line 492 of file Log.cxx.
References setThreadSetting().
{
Log::setThreadSetting(ThreadSetting(serv, getServiceLevel(serv)));
}

| EncodeStream & Log::tags | ( | Log::Level | level, |
| const Subsystem & | subsystem, | ||
| const char * | file, | ||
| int | line, | ||
| EncodeStream & | strm | ||
| ) | [static] |
output the loglevel, hostname, appname, pid, tid, subsystem
Definition at line 336 of file Log.cxx.
References resip::Data::Borrow, and delim.
Referenced by resip::Log::Guard::Guard().
{
char buffer[256];
Data ts(Data::Borrow, buffer, sizeof(buffer));
#if defined( __APPLE__ )
strm << mDescriptions[level+1] << Log::delim
<< timestamp(ts) << Log::delim
<< mAppName << Log::delim
<< subsystem << Log::delim
<< pthread_self() << Log::delim
<< pfile << ":" << line;
#elif defined( WIN32 )
const char* file = pfile + strlen(pfile);
while (file != pfile &&
*file != '\\')
{
--file;
}
if (file != pfile)
{
++file;
}
strm << mDescriptions[level+1] << Log::delim
<< timestamp(ts) << Log::delim
<< mAppName << Log::delim
<< subsystem << Log::delim
<< GetCurrentThreadId() << Log::delim
<< file << ":" << line;
#else // #if defined( WIN32 ) || defined( __APPLE__ )
strm << mDescriptions[level+1] << Log::delim
<< timestamp(ts) << Log::delim
// << mHostname << Log::delim
<< mAppName << Log::delim
<< subsystem << Log::delim
// << mPid << Log::delim
<< pthread_self() << Log::delim
<< pfile << ":" << line;
#endif
return strm;
}
Definition at line 390 of file Log.cxx.
References resip::Data::at(), resip::Data::clear(), and resip::Data::data().
{
char* datebuf = const_cast<char*>(res.data());
const unsigned int datebufSize = 256;
res.clear();
#ifdef WIN32
int result = 1;
SYSTEMTIME systemTime;
struct { time_t tv_sec; int tv_usec; } tv = {0,0};
time(&tv.tv_sec);
GetLocalTime(&systemTime);
tv.tv_usec = systemTime.wMilliseconds * 1000;
#else
struct timeval tv;
int result = gettimeofday (&tv, NULL);
#endif
if (result == -1)
{
/* If we can't get the time of day, don't print a timestamp.
Under Unix, this will never happen: gettimeofday can fail only
if the timezone is invalid which it can't be, since it is
uninitialized]or if tv or tz are invalid pointers. */
datebuf [0] = 0;
}
else
{
/* The tv_sec field represents the number of seconds passed since
the Epoch, which is exactly the argument gettimeofday needs. */
const time_t timeInSeconds = (time_t) tv.tv_sec;
strftime (datebuf,
datebufSize,
"%Y%m%d-%H%M%S", /* guaranteed to fit in 256 chars,
hence don't check return code */
localtime (&timeInSeconds));
}
char msbuf[5];
/* Dividing (without remainder) by 1000 rounds the microseconds
measure to the nearest millisecond. */
sprintf(msbuf, ".%3.3ld", long(tv.tv_usec / 1000));
int datebufCharsRemaining = datebufSize - (int)strlen(datebuf);
strncat (datebuf, msbuf, datebufCharsRemaining - 1);
datebuf[datebufSize - 1] = '\0'; /* Just in case strncat truncated msbuf,
thereby leaving its last character at
the end, instead of a null terminator */
// ugh, resize the Data
res.at(strlen(datebuf)-1);
return res;
}

| Data Log::timestamp | ( | ) | [static] |
Definition at line 382 of file Log.cxx.
References resip::Data::Borrow.
{
char buffer[256];
Data result(Data::Borrow, buffer, sizeof(buffer));
return timestamp(result);
}
| Log::Level Log::toLevel | ( | const Data & | l | ) | [static] |
Definition at line 296 of file Log.cxx.
References Debug, resip::Data::prefix(), and resip::Data::substr().
Referenced by main().
{
Data pri( l.prefix("LOG_") ? l.substr(4) : l);
int i=0;
while (strlen(mDescriptions[i]))
{
if (strcmp(pri.c_str(), mDescriptions[i]) == 0)
{
return Level(i-1);
}
i++;
}
cerr << "Choosing Debug level since string was not understood: " << l << endl;
return Log::Debug;
}

| resip::Log::void::freeLocalLogger | ( | void * | pThreadData | ) | [protected] |
friend class LogStaticInitializer [friend] |
Mutex Log::_mutex [static, protected] |
Definition at line 262 of file Log.hxx.
Referenced by id(), level(), and resip::Log::Guard::~Guard().
const Data Log::delim [static, protected] |
Definition at line 264 of file Log.hxx.
Referenced by resip::Log::Guard::Guard(), and tags().
Data Log::mAppName [static, protected] |
Definition at line 324 of file Log.hxx.
Referenced by getAppName().
unsigned int Log::MaxByteCount = 0 [static] |
Definition at line 259 of file Log.hxx.
Referenced by resip::Log::ThreadData::maxByteCount().
unsigned int Log::MaxLineCount = 0 [static] |
Definition at line 258 of file Log.hxx.
Referenced by resip::Log::ThreadData::maxLineCount().
Log::ThreadData Log::mDefaultLoggerData [static, protected] |
const char Log::mDescriptions = {"NONE", "EMERG", "ALERT", "CRIT", "ERR", "WARNING", "NOTICE", "INFO", "DEBUG", "STACK", "CERR", ""} [static, protected] |
Data Log::mHostname [static, protected] |
ThreadIf::TlsKey* resip::Log::mLevelKey [static, protected] |
Definition at line 397 of file Log.hxx.
Referenced by getThreadSetting(), resip::LogStaticInitializer::LogStaticInitializer(), and resip::LogStaticInitializer::~LogStaticInitializer().
ThreadIf::TlsKey * Log::mLocalLoggerKey [static, protected] |
Definition at line 390 of file Log.hxx.
Referenced by getLoggerData(), resip::LogStaticInitializer::LogStaticInitializer(), setThreadLocalLogger(), and resip::LogStaticInitializer::~LogStaticInitializer().
Log::LocalLoggerMap Log::mLocalLoggerMap [static, protected] |
Definition at line 389 of file Log.hxx.
Referenced by freeLocalLogger().
HashMap< int, Log::Level > Log::mServiceToLevel [static, protected] |
DEPRECATED! Left for backward compatibility - use localLoggers instead.
Definition at line 399 of file Log.hxx.
Referenced by getServiceLevel(), and setServiceLevel().
HashMap<int, std::set<ThreadIf::Id> > resip::Log::mServiceToThreads [static, protected] |
Definition at line 396 of file Log.hxx.
Referenced by setServiceLevel(), and setThreadSetting().
HashMap<ThreadIf::Id, std::pair<ThreadSetting, bool> > resip::Log::mThreadToLevel [static, protected] |
DEPRECATED! Left for backward compatibility - use localLoggers instead.
Definition at line 395 of file Log.hxx.
Referenced by getThreadSetting(), setServiceLevel(), and setThreadSetting().
volatile short Log::touchCount = 0 [static, protected] |
Definition at line 263 of file Log.hxx.
Referenced by getThreadSetting(), and setServiceLevel().
1.7.5.1