log.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00033 #ifndef __log__header__
00034 #define __log__header__
00035
00036 #include "gpucalc/object.h"
00037
00038 namespace gpucalc
00039 {
00040 const char _LogClassName [] = "Log";
00041
00042
00048 const int Log_Threshold = 4;
00049
00050
00054 enum LoggingLevel
00055 {
00056 LL_Low = 1,
00057 LL_Normal = 2,
00058 LL_Verbose = 3
00059 };
00060
00061
00065 enum LogMessageLevel
00066 {
00067 LML_Trivial = 1,
00068 LML_Normal = 2,
00069 LML_Critical = 3
00070 };
00071
00072 const char _LogListenerClassName [] = "LogListener";
00073
00077 class _GpuCalcExport LogListener: public Object
00078 {
00079 public:
00080
00081 LogListener(const std::string & LogListenerName): Object(_LogListenerClassName, LogListenerName)
00082 {}
00083
00084 virtual ~LogListener()
00085 {
00086 }
00087
00088
00096 virtual void MessageLogged(const std::string & message, LogMessageLevel lml,
00097 bool maskDebug, const std::string & logName) = 0;
00098 };
00099
00100
00104 class _GpuCalcExport Log: public Object
00105 {
00106 public:
00107 Log(const std::string & LogName, unsigned int LogClassNameAlignment = 15, unsigned int LogObjectNameAlignment = 20,
00108 bool DebugOutput = true, bool SuppressFileOutput = false, bool SuppressObjectInfo = false);
00109
00110
00111 ~Log();
00112
00113
00117 void logMessage(const Object & object, const std::string & Message,
00118 LogMessageLevel lml = LML_Normal, bool maskDebug = false);
00119
00120
00121 void logMessage(const Object * object, const std::string & Message,
00122 LogMessageLevel lml = LML_Normal, bool maskDebug = false);
00123
00124
00128 bool isDebugOutputEnabled() const
00129 {
00130 return mDebugOutput;
00131 }
00132
00133
00137 bool isFileOutputSuppressed() const
00138 {
00139 return mSuppressFile;
00140 }
00141
00142
00146 void setDebugOutputEnabled(bool debugOutput)
00147 {
00148 mDebugOutput = debugOutput;
00149 }
00150
00151
00155 void setLogDetail(LoggingLevel ll)
00156 {
00157 mLogLevel = ll;
00158 }
00159
00160
00161 void setTimeOutputEnabled(bool TimeOutput)
00162 {
00163 mTimeOutput = TimeOutput;
00164 }
00165
00166
00167 LoggingLevel getLogDetail()
00168 {
00169 return mLogLevel;
00170 }
00171
00172
00176 LoggingLevel getLogDetail() const
00177 {
00178 return mLogLevel;
00179 }
00180
00181
00186 void addListener(LogListener * listener);
00187
00188
00193 void removeListener(LogListener * listener);
00194
00195
00196 private:
00197 std::ofstream mfpLog;
00198 LoggingLevel mLogLevel;
00199 bool mDebugOutput;
00200 bool mSuppressFile;
00201 bool mSuppressObjectInfo;
00202 bool mTimeOutput;
00203 unsigned int mLogClassNameAlignment;
00204 unsigned int mLogObjectNameAlignment;
00205
00206 typedef std::list<LogListener *> mtLogListener;
00207 mtLogListener mListeners;
00208
00209 void logMessage(const std::string & message, LogMessageLevel lml = LML_Normal, bool maskDebug = false);
00210
00211 };
00212 }
00213
00214 #endif