Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

CSLog Class Reference

#include <CSLog.h>


Public Member Functions

void print (int level, const std::string &text)
void print (int level, const std::string &text, int value)
void print (int level, const std::string &text, long value)
void print (int level, const std::string &text, float value)
void startFunction (const std::string &methodName, const std::string &className)
void endFunction ()
void setDebugType (int type)
int getDebugType ()
void setDebugLevel (int level)
int getDebugLevel ()
void addCallback (CSLogCallback *callback)
void removeCallback (CSLogCallback *callback)
void setFunctionTracking (bool b)
 Debug Level.

void setShortMessage (bool b)
void setOnlyTrackClass (const std::string &className)
void setOnlyTrackMethod (const std::string &methodName)

Static Public Member Functions

CSLoggetInstance (const std::string &identifier)
void deleteInstance (const std::string &identifier)


Member Function Documentation

CSLog * CSLog::getInstance const std::string &  identifier  )  [static]
 

Definition at line 192 of file CSLog.cpp.

00193 {
00194     CSLog *instance = 0;
00195     try
00196     {
00197         LogMap::iterator iter = mMap.find(identifier);
00198         if (iter != mMap.end())
00199         {
00200             instance = iter->second;
00201         }
00202         else
00203         {
00204             instance = new CSLog(identifier);
00205             mMap.insert(LogMap::value_type(identifier, instance));
00206         }
00207     }
00208     catch (...)
00209     {
00210     }
00211     return instance;
00212 }

void CSLog::deleteInstance const std::string &  identifier  )  [static]
 

Definition at line 214 of file CSLog.cpp.

00215 {
00216     CSLog *instance = 0;
00217     LogMap::iterator iter = mMap.find(identifier);
00218     if (iter != mMap.end())
00219     {
00220         instance = iter->second;
00221         delete(instance);
00222         mMap.erase(iter);
00223     }
00224 }

void CSLog::print int  level,
const std::string &  text
 

Definition at line 226 of file CSLog.cpp.

Referenced by print().

00227 {
00228     printInternal(level, text);
00229 }

void CSLog::print int  level,
const std::string &  text,
int  value
 

Definition at line 240 of file CSLog.cpp.

References print().

00241 {
00242     std::string newText;
00243     static char valueText[80];
00244     sprintf(valueText, "%i", value);
00245     newText = text + valueText;
00246     print(level, newText);
00247 }

Here is the call graph for this function:

void CSLog::print int  level,
const std::string &  text,
long  value
 

Definition at line 231 of file CSLog.cpp.

References print().

00232 {
00233     std::string newText;
00234     static char valueText[80];
00235     sprintf(valueText, "%i", value);
00236     newText = text + valueText;
00237     print(level, newText);
00238 }

Here is the call graph for this function:

void CSLog::print int  level,
const std::string &  text,
float  value
 

Definition at line 249 of file CSLog.cpp.

References print().

00250 {
00251     std::string newText;
00252     static char valueText[80];
00253     sprintf(valueText, "%f", value);
00254     newText = text + valueText;
00255     print(level, newText);
00256 }

Here is the call graph for this function:

void CSLog::startFunction const std::string &  methodName,
const std::string &  className
 

Definition at line 258 of file CSLog.cpp.

References LOG_LEVEL_DEBUG.

00259 {
00260     mFunctionDepth++;
00261     mCurrentMethod[mFunctionDepth] = methodName;
00262     mCurrentClass[mFunctionDepth] = className;
00263     if (mFunctionTracking)
00264     {
00265 #ifdef SDL_TIMING
00266         mCurrentTime[mFunctionDepth] = SDL_GetTicks();
00267 #endif
00268         if (!mShortMessage)
00269         {
00270             printInternal(LOG_LEVEL_DEBUG, ((std::string) "Entering..."));
00271         }
00272     }
00273 }

void CSLog::endFunction  ) 
 

Definition at line 275 of file CSLog.cpp.

References LOG_LEVEL_DEBUG.

00276 {
00277     if (!mShortMessage)
00278     {
00279         if (mFunctionTracking)
00280         {
00281 #ifdef SDL_TIMING
00282             long timeBetween = SDL_GetTicks() - mCurrentTime[mFunctionDepth];
00283             mCurrentTime[mFunctionDepth] = 0;
00284             std::string newText;
00285             static char valueText[80];
00286             sprintf(valueText, "Time remaining in Method (ms): %i", timeBetween);
00287             printInternal(LOG_LEVEL_DEBUG, ((std::string) "Exiting... " + valueText));
00288 #else
00289             printInternal(LOG_LEVEL_DEBUG, ((std::string) "Exiting..."));
00290 #endif
00291         }
00292     }
00293     mCurrentMethod[mFunctionDepth] = "";
00294     mCurrentClass[mFunctionDepth] = "";
00295     mFunctionDepth--;
00296     if (mFunctionDepth < 0) 
00297     {
00298         mFunctionDepth = 0;
00299     }
00300 }

void CSLog::setDebugType int  type  ) 
 

Definition at line 302 of file CSLog.cpp.

00303 {
00304     mDebugType = type;
00305 }

int CSLog::getDebugType  ) 
 

Definition at line 307 of file CSLog.cpp.

00308 {
00309     return mDebugType;
00310 }

void CSLog::setDebugLevel int  level  ) 
 

Definition at line 312 of file CSLog.cpp.

00313 {
00314     mLogLevel = level;
00315 }

int CSLog::getDebugLevel  ) 
 

Definition at line 317 of file CSLog.cpp.

00318 {
00319     return mLogLevel;
00320 }

void CSLog::addCallback CSLogCallback callback  ) 
 

Definition at line 322 of file CSLog.cpp.

References removeCallback().

00323 {
00324     removeCallback(callback);
00325     mCallbacks.push_back(callback);
00326 }

Here is the call graph for this function:

void CSLog::removeCallback CSLogCallback callback  ) 
 

Definition at line 328 of file CSLog.cpp.

Referenced by addCallback().

00329 {
00330     CSLogCallbacks::iterator iter = mCallbacks.begin();
00331     while ( iter != mCallbacks.end())
00332     {
00333         if ((*iter) == callback)
00334         {
00335             mCallbacks.erase(iter);
00336             iter = mCallbacks.begin();  // restart!
00337         }
00338         else
00339         {
00340             iter++;
00341         }
00342     }
00343 }

void CSLog::setFunctionTracking bool  b  )  [inline]
 

Debug Level.

Definition at line 229 of file CSLog.h.

void CSLog::setShortMessage bool  b  )  [inline]
 

Definition at line 230 of file CSLog.h.

00230 {mShortMessage = b;} 

void CSLog::setOnlyTrackClass const std::string &  className  )  [inline]
 

Only up to characters of name givven are compared, that means name - "r" enables to track all classes beginning with "r"!

Definition at line 235 of file CSLog.h.

00235 {mTrackClassName = className;}

void CSLog::setOnlyTrackMethod const std::string &  methodName  )  [inline]
 

Definition at line 236 of file CSLog.h.

00236 {mTrackMethodName = methodName;}


Generated on Wed Jul 14 00:44:47 2004 for CSLib by doxygen 1.3.6