#include <log_manager.h>
Public Member Functions | |
Log * | createLog (const std::string &name, bool defaultLog=false, unsigned int LogClassNameAlignment=15, unsigned int LogObjectNameAlignment=20, bool DebugOutput=true, bool SuppressFileOutput=false, bool SuppressObjectInfo=false) |
Creates a new log with the given name. | |
void | destroyLog (Log *log) |
Closes and removes a log. | |
void | destroyLog (const std::string &name) |
Closes and removes a named log. | |
const std::string & | getClassName () const |
Returns name of class of our object. | |
Log * | getDefaultLog () |
Returns a pointer to the default log. | |
Log * | getLog (const std::string &name) |
Retrieves a log managed by this class. | |
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 | isLocked () const |
returns state of object. | |
LogManager () | |
void | logMessage (const std::string &LogId, const Object &object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false) |
void | logMessage (const std::string &LogId, 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) |
void | logMessage (const Object &object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false) |
Log a message to the default log. | |
template<> | |
Timer * | mSingleton |
template<> | |
Timer * | mSingleton |
template<> | |
Profiler * | mSingleton |
template<> | |
LogManager * | mSingleton |
template<> | |
debugger::Debugger * | mSingleton |
template<> | |
debugger::CommandParser * | mSingleton |
template<> | |
Application * | mSingleton |
Log * | setDefaultLog (Log *newLog) |
Sets the passed in log as the default log. | |
void | setLogDetail (LoggingLevel ll) |
Sets the level of detail of the default log. | |
~LogManager () | |
Static Public Member Functions | |
static LogManager & | getSingleton () |
static LogManager * | getSingletonPtr () |
Protected Types | |
typedef std::map< std::string, Log *, std::less< std::string > > | LogMap |
Protected Member Functions | |
void | addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size) |
void | lock () |
void | unlock () |
Protected Attributes | |
Log * | mDefaultLog |
The default log to which output is done. | |
LogMap | mLogMap |
A list of all the logs the manager can access. | |
Static Protected Attributes | |
static T * | mSingleton |
This class creates one log, and provide logging into it.
Definition at line 48 of file log_manager.h.
typedef std::map<std::string, Log *, std::less<std::string> > gpucalc::LogManager::LogMap [protected] |
Definition at line 160 of file log_manager.h.
gpucalc::LogManager::LogManager | ( | ) |
Definition at line 54 of file log_manager.cpp.
00054 : Singleton<LogManager>(_LogManagerObjectName), mLogMap(), mDefaultLog(0) 00055 { 00056 }
gpucalc::LogManager::~LogManager | ( | ) |
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 }
Log * gpucalc::LogManager::createLog | ( | const std::string & | name, | |
bool | defaultLog = false , |
|||
unsigned int | LogClassNameAlignment = 15 , |
|||
unsigned int | LogObjectNameAlignment = 20 , |
|||
bool | DebugOutput = true , |
|||
bool | SuppressFileOutput = false , |
|||
bool | SuppressObjectInfo = false | |||
) |
Creates a new log with the given name.
name | - The name to give the log e.g. 'test.log'. | |
defaultLog | - If true, this is the default log output will be sent to if the generic logging methods on this class are used. The first log created is always the default log unless this parameter is set. | |
LogClassNameAlignment | - length of field of ClassName in log. | |
LogObjectNameAlignment | - length of field of ObjectName in log. | |
DebugOutput | - If true, output to this log will also be routed to the debugger's output window. | |
SuppressFileOutput | - If true, this is a logical rather than a physical log and no file output will be written. If you do this you should register a LogListener so log output is not lost. | |
SuppressObjectInfo | - if true does not log class name and object name. |
Definition at line 65 of file log_manager.cpp.
00067 { 00068 Log * newLog = new Log(name, LogClassNameAlignment, LogObjectNameAlignment, DebugOutput, SuppressFileOutput, SuppressObjectInfo); 00069 if( !mDefaultLog || defaultLog ) 00070 { 00071 mDefaultLog = newLog; 00072 } 00073 addToContainer(newLog, name, mLogMap); 00074 return newLog; 00075 }
void gpucalc::LogManager::destroyLog | ( | Log * | log | ) |
Closes and removes a log.
Definition at line 128 of file log_manager.cpp.
00129 { 00130 destroyLog(log->getObjectName()); 00131 }
void gpucalc::LogManager::destroyLog | ( | const std::string & | name | ) |
Closes and removes a named log.
Set another default log if this one removed
Definition at line 107 of file log_manager.cpp.
00108 { 00109 LogMap::iterator i = mLogMap.find(name); 00110 if (i != mLogMap.end()) 00111 { 00112 if (mDefaultLog == i->second) 00113 { 00114 mDefaultLog = NULL; 00115 } 00116 delete i->second; 00117 mLogMap.erase(i); 00118 } 00119 00121 if (!mDefaultLog && !mLogMap.empty()) 00122 { 00123 mDefaultLog = mLogMap.begin()->second; 00124 } 00125 }
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 }
Log * gpucalc::LogManager::getDefaultLog | ( | ) |
Returns a pointer to the default log.
Definition at line 78 of file log_manager.cpp.
00079 { 00080 return mDefaultLog; 00081 }
Log * gpucalc::LogManager::getLog | ( | const std::string & | name | ) |
Retrieves a log managed by this class.
Definition at line 92 of file log_manager.cpp.
00093 { 00094 LogMap::iterator i = mLogMap.find(name); 00095 if (i != mLogMap.end()) 00096 { 00097 return i->second; 00098 } 00099 else 00100 { 00101 Except<ERR_INVALIDPARAMS>(this, "Log not found. ", "LogManager::getLog", __FILE__, __LINE__); 00102 return NULL; 00103 } 00104 }
LoggingLevel gpucalc::LogManager::getLogDetail | ( | ) |
Definition at line 194 of file log_manager.cpp.
00195 { 00196 if (mDefaultLog) 00197 { 00198 return mDefaultLog->getLogDetail(); 00199 } 00200 return LL_Low; 00201 }
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 }
LogManager & gpucalc::LogManager::getSingleton | ( | ) | [static] |
Override standard Singleton retrieval.
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.
Reimplemented from gpucalc::Singleton< T >.
Definition at line 47 of file log_manager.cpp.
00048 { 00049 assert(mSingleton); 00050 return(* mSingleton); 00051 }
LogManager * gpucalc::LogManager::getSingletonPtr | ( | ) | [static] |
Override standard Singleton retrieval.
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.
Reimplemented from gpucalc::Singleton< T >.
Definition at line 41 of file log_manager.cpp.
00042 { 00043 return mSingleton; 00044 }
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::Object::isLocked | ( | ) | const [inline, inherited] |
void gpucalc::Object::lock | ( | ) | [inline, protected, inherited] |
void gpucalc::LogManager::logMessage | ( | const std::string & | LogId, | |
const Object & | object, | |||
const std::string & | Message, | |||
LogMessageLevel | lml = LML_Normal , |
|||
bool | maskDebug = false | |||
) |
Definition at line 169 of file log_manager.cpp.
00171 { 00172 LogMap::iterator i = mLogMap.find(LogId); 00173 if (i != mLogMap.end()) 00174 { 00175 i->second->logMessage(object, Message, lml, maskDebug); 00176 } 00177 else 00178 { 00179 Except<ERR_ITEM_NOT_FOUND>(this, "Log with Id \"" + LogId + "\" cannot be found.", "LogManager::logMessage()", __FILE__, __LINE__); 00180 } 00181 }
void gpucalc::LogManager::logMessage | ( | const std::string & | LogId, | |
const Object * | object, | |||
const std::string & | Message, | |||
LogMessageLevel | lml = LML_Normal , |
|||
bool | maskDebug = false | |||
) |
Definition at line 155 of file log_manager.cpp.
00157 { 00158 LogMap::iterator i = mLogMap.find(LogId); 00159 if (i != mLogMap.end()) 00160 { 00161 i->second->logMessage(object, Message, lml, maskDebug); 00162 } 00163 else 00164 { 00165 Except<ERR_ITEM_NOT_FOUND>(this, "Log with Id \"" + LogId + "\" cannot be found.", "LogManager::logMessage()", __FILE__, __LINE__); 00166 } 00167 }
void gpucalc::LogManager::logMessage | ( | const Object * | object, | |
const std::string & | Message, | |||
LogMessageLevel | lml = LML_Normal , |
|||
bool | maskDebug = false | |||
) |
Definition at line 145 of file log_manager.cpp.
00147 { 00148 if (mDefaultLog) 00149 { 00150 mDefaultLog->logMessage(object, Message, lml, maskDebug); 00151 } 00152 }
void gpucalc::LogManager::logMessage | ( | const Object & | object, | |
const std::string & | Message, | |||
LogMessageLevel | lml = LML_Normal , |
|||
bool | maskDebug = false | |||
) |
Log a message to the default log.
Definition at line 134 of file log_manager.cpp.
00136 { 00137 if (mDefaultLog) 00138 { 00139 mDefaultLog->logMessage(object, Message, lml, maskDebug); 00140 } 00141 }
Timer * gpucalc::Singleton< Timer >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 42 of file win32_timer_impl.cpp.
Timer * gpucalc::Singleton< Timer >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 45 of file unix_timer_impl.cpp.
Profiler * gpucalc::Singleton< Profiler >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 39 of file profiler.cpp.
LogManager * gpucalc::Singleton< LogManager >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 38 of file log_manager.cpp.
debugger::Debugger * gpucalc::Singleton< debugger::Debugger >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 42 of file debugger.cpp.
debugger::CommandParser * gpucalc::Singleton< debugger::CommandParser >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 41 of file command_parser.cpp.
Application * gpucalc::Singleton< Application >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 44 of file application.cpp.
Sets the passed in log as the default log.
Definition at line 84 of file log_manager.cpp.
00085 { 00086 Log * oldLog = mDefaultLog; 00087 mDefaultLog = newLog; 00088 return oldLog; 00089 }
void gpucalc::LogManager::setLogDetail | ( | LoggingLevel | ll | ) |
Sets the level of detail of the default log.
Definition at line 185 of file log_manager.cpp.
00186 { 00187 if (mDefaultLog) 00188 { 00189 mDefaultLog->setLogDetail(ll); 00190 } 00191 }
void gpucalc::Object::unlock | ( | ) | [inline, protected, inherited] |
Log* gpucalc::LogManager::mDefaultLog [protected] |
LogMap gpucalc::LogManager::mLogMap [protected] |
T* gpucalc::Singleton< T >::mSingleton [static, protected, inherited] |
Definition at line 108 of file singleton.h.