#include <log.h>
Public Member Functions | |
void | addListener (LogListener *listener) |
Register a listener to this log. | |
const std::string & | getClassName () const |
Returns name of class of our object. | |
LoggingLevel | getLogDetail () const |
Gets the level of the log detail. | |
LoggingLevel | getLogDetail () |
const std::string & | getObjectName () const |
Returns name of our object. | |
void | getSpecificParameter (const std::string &ParameterName, void *ParameterValue) |
Method for obtaining some specific parameters, such as texture specific params, and so on. | |
bool | isDebugOutputEnabled () const |
Get whether debug output is enabled for this log. | |
bool | isFileOutputSuppressed () const |
Get whether file output is suppressed for this log. | |
bool | isLocked () const |
returns state of object. | |
Log (const std::string &LogName, unsigned int LogClassNameAlignment=15, unsigned int LogObjectNameAlignment=20, bool DebugOutput=true, bool SuppressFileOutput=false, bool SuppressObjectInfo=false) | |
void | logMessage (const Object *object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false) |
void | logMessage (const Object &object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false) |
Log a message to the debugger and to log file (the default is "<code>gpucalc.log</code>"). | |
void | removeListener (LogListener *listener) |
Unregister a listener from this log. | |
void | setDebugOutputEnabled (bool debugOutput) |
Enable or disable outputting log messages to the debugger. | |
void | setLogDetail (LoggingLevel ll) |
Sets the level of the log detail. | |
void | setTimeOutputEnabled (bool TimeOutput) |
~Log () | |
Protected Member Functions | |
void | addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size) |
void | lock () |
void | unlock () |
Private Types | |
typedef std::list< LogListener * > | mtLogListener |
Private Member Functions | |
void | logMessage (const std::string &message, LogMessageLevel lml=LML_Normal, bool maskDebug=false) |
Private Attributes | |
bool | mDebugOutput |
std::ofstream | mfpLog |
mtLogListener | mListeners |
unsigned int | mLogClassNameAlignment |
LoggingLevel | mLogLevel |
unsigned int | mLogObjectNameAlignment |
bool | mSuppressFile |
bool | mSuppressObjectInfo |
bool | mTimeOutput |
Definition at line 104 of file log.h.
typedef std::list<LogListener *> gpucalc::Log::mtLogListener [private] |
gpucalc::Log::Log | ( | const std::string & | LogName, | |
unsigned int | LogClassNameAlignment = 15 , |
|||
unsigned int | LogObjectNameAlignment = 20 , |
|||
bool | DebugOutput = true , |
|||
bool | SuppressFileOutput = false , |
|||
bool | SuppressObjectInfo = false | |||
) |
Definition at line 42 of file log.cpp.
00043 : 00044 Object(_LogClassName, LogName), mLogLevel(LL_Normal), mDebugOutput(DebugOutput), mSuppressFile(SuppressFileOutput), 00045 mSuppressObjectInfo(SuppressObjectInfo), mTimeOutput(true), mLogClassNameAlignment(LogClassNameAlignment), mLogObjectNameAlignment(LogObjectNameAlignment) 00046 { 00047 if (!mSuppressFile) 00048 { 00049 mfpLog.open(LogName.c_str()); 00050 } 00051 }
gpucalc::Log::~Log | ( | ) |
Definition at line 54 of file log.cpp.
00055 { 00056 if (!mSuppressFile) 00057 { 00058 mfpLog.close(); 00059 } 00060 }
void gpucalc::Log::addListener | ( | LogListener * | listener | ) |
Register a listener to this log.
listener | - A valid listener derived class. |
Definition at line 123 of file log.cpp.
00124 { 00125 mListeners.push_back(listener); 00126 }
void gpucalc::Object::addSpecificParameter | ( | const std::string & | ParameterName, | |
void * | ParameterValue, | |||
size_t | Size | |||
) | [inline, protected, inherited] |
Definition at line 254 of file object.h.
00255 { 00256 SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName); 00257 if (i != mSpecificParameters.end()) 00258 { 00259 mSpecificParameters.erase(i); 00260 } 00261 mSpecificParameters[ParameterName] = Any(ParameterValue, Size); 00262 }
const std::string& gpucalc::Object::getClassName | ( | ) | const [inline, inherited] |
Returns name of class of our object.
Definition at line 92 of file object.h.
00093 { 00094 return mClassName; 00095 }
LoggingLevel gpucalc::Log::getLogDetail | ( | ) | const [inline] |
LoggingLevel gpucalc::Log::getLogDetail | ( | ) | [inline] |
const std::string& gpucalc::Object::getObjectName | ( | ) | const [inline, inherited] |
Returns name of our object.
Definition at line 101 of file object.h.
00102 { 00103 return mObjectName; 00104 }
void gpucalc::Object::getSpecificParameter | ( | const std::string & | ParameterName, | |
void * | ParameterValue | |||
) | [inline, inherited] |
Method for obtaining some specific parameters, such as texture specific params, and so on.
ParameterName | - name of parameter, usually it similar to specific method of some object (for example, GLTextureID) | |
ParameterValue | - contain value of named parameter, it must be allocated and have sufficient size. |
Definition at line 128 of file object.h.
00129 { 00130 SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName); 00131 if (i != mSpecificParameters.end()) 00132 { 00133 i->second.copyValue(ParameterValue); 00134 } 00135 else 00136 { 00137 Except<ERR_ITEM_NOT_FOUND>(this, "Parameter \"" + ParameterName + "\" does not exists.", "Object::getSpecificParameter()", __FILE__, __LINE__); 00138 } 00139 }
bool gpucalc::Log::isDebugOutputEnabled | ( | ) | const [inline] |
Get whether debug output is enabled for this log.
Definition at line 128 of file log.h.
00129 { 00130 return mDebugOutput; 00131 }
bool gpucalc::Log::isFileOutputSuppressed | ( | ) | const [inline] |
Get whether file output is suppressed for this log.
Definition at line 137 of file log.h.
00138 { 00139 return mSuppressFile; 00140 }
bool gpucalc::Object::isLocked | ( | ) | const [inline, inherited] |
void gpucalc::Object::lock | ( | ) | [inline, protected, inherited] |
void gpucalc::Log::logMessage | ( | const std::string & | message, | |
LogMessageLevel | lml = LML_Normal , |
|||
bool | maskDebug = false | |||
) | [private] |
Definition at line 63 of file log.cpp.
00064 { 00065 for (mtLogListener::iterator i = mListeners.begin(); i != mListeners.end(); ++i) 00066 { 00067 (*i)->MessageLogged(message, lml, maskDebug, this->getObjectName()); 00068 } 00069 if (mDebugOutput && !maskDebug) 00070 { 00071 std::cerr << message << std::endl; 00072 } 00073 if (!mSuppressFile) 00074 { 00075 struct tm *pTime; 00076 time_t ctTime; 00077 time(&ctTime); 00078 pTime = localtime(&ctTime); 00079 00080 if (mTimeOutput) 00081 { 00082 mfpLog << std::setw(2) << std::setfill('0') << pTime->tm_hour 00083 << ":" << std::setw(2) << std::setfill('0') << pTime->tm_min 00084 << ":" << std::setw(2) << std::setfill('0') << pTime->tm_sec 00085 << ": "; 00086 } 00087 mfpLog << message << std::endl; 00088 00089 mfpLog.flush(); 00090 } 00091 }
void gpucalc::Log::logMessage | ( | const Object * | object, | |
const std::string & | Message, | |||
LogMessageLevel | lml = LML_Normal , |
|||
bool | maskDebug = false | |||
) |
Definition at line 115 of file log.cpp.
00117 { 00118 assert(object && "Cannot log noninitialized object!!!"); 00119 logMessage(*object, Message, lml, maskDebug); 00120 }
void gpucalc::Log::logMessage | ( | const Object & | object, | |
const std::string & | Message, | |||
LogMessageLevel | lml = LML_Normal , |
|||
bool | maskDebug = false | |||
) |
Log a message to the debugger and to log file (the default is "<code>gpucalc.log</code>").
Definition at line 94 of file log.cpp.
00096 { 00097 if ((mLogLevel + lml) >= Log_Threshold) 00098 { 00099 if (!mSuppressObjectInfo) 00100 { 00101 logMessage( 00102 auxillary::StringUtil::getFixedString(object.getClassName(), mLogClassNameAlignment, "", ":") + 00103 auxillary::StringUtil::getFixedString(object.getObjectName(), mLogObjectNameAlignment, "", ":") + 00104 Message, lml, maskDebug 00105 ); 00106 } 00107 else 00108 { 00109 logMessage(Message, lml, maskDebug); 00110 } 00111 } 00112 }
void gpucalc::Log::removeListener | ( | LogListener * | listener | ) |
Unregister a listener from this log.
listener | - A valid listener derived class. |
Definition at line 129 of file log.cpp.
00130 { 00131 mListeners.erase(std::find(mListeners.begin(), mListeners.end(), listener)); 00132 }
void gpucalc::Log::setDebugOutputEnabled | ( | bool | debugOutput | ) | [inline] |
Enable or disable outputting log messages to the debugger.
Definition at line 146 of file log.h.
00147 { 00148 mDebugOutput = debugOutput; 00149 }
void gpucalc::Log::setLogDetail | ( | LoggingLevel | ll | ) | [inline] |
void gpucalc::Log::setTimeOutputEnabled | ( | bool | TimeOutput | ) | [inline] |
void gpucalc::Object::unlock | ( | ) | [inline, protected, inherited] |
bool gpucalc::Log::mDebugOutput [private] |
std::ofstream gpucalc::Log::mfpLog [private] |
mtLogListener gpucalc::Log::mListeners [private] |
unsigned int gpucalc::Log::mLogClassNameAlignment [private] |
LoggingLevel gpucalc::Log::mLogLevel [private] |
unsigned int gpucalc::Log::mLogObjectNameAlignment [private] |
bool gpucalc::Log::mSuppressFile [private] |
bool gpucalc::Log::mSuppressObjectInfo [private] |
bool gpucalc::Log::mTimeOutput [private] |