00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _CEGUILogger_h_
00027 #define _CEGUILogger_h_
00028
00029 #include "CEGUIBase.h"
00030 #include "CEGUIString.h"
00031 #include <fstream>
00032 #include <sstream>
00033 #include <vector>
00034 #include <utility>
00035 #include "CEGUISingleton.h"
00036
00037
00038 #if defined(_MSC_VER)
00039 # pragma warning(push)
00040 # pragma warning(disable : 4275)
00041 # pragma warning(disable : 4251)
00042 #endif
00043
00044
00045
00046 namespace CEGUI
00047 {
00048
00053 enum LoggingLevel
00054 {
00055 Errors,
00056 Standard,
00057 Informative,
00058 Insane
00059 };
00060
00065 class CEGUIEXPORT Logger : public Singleton <Logger>
00066 {
00067 public:
00072 Logger(void);
00073
00077 ~Logger(void);
00078
00079
00087 static Logger& getSingleton(void);
00088
00089
00100 void setLoggingLevel(LoggingLevel level) {d_level = level;}
00101
00102
00110 LoggingLevel getLoggingLevel(void) const {return d_level;}
00111
00112
00126 void logEvent(const String& message, LoggingLevel level = Standard);
00127
00143 void setLogFilename(const String& filename, bool append = false);
00144
00145 protected:
00146
00147
00148
00149 LoggingLevel d_level;
00150 std::ofstream d_ostream;
00151 std::vector<std::pair<String, LoggingLevel> > d_cache;
00152 std::ostringstream d_workstream;
00153 bool d_caching;
00154
00155 private:
00156
00157
00158
00159 Logger(const Logger& logger) {}
00160 Logger& operator=(const Logger& logger) {return *this;}
00161
00162 };
00163
00164
00165
00166
00167
00168 #if defined(DEBUG) || defined (_DEBUG)
00169 # define CEGUI_LOGINSANE( message ) CEGUI::Logger::getSingleton().logEvent((message), CEGUI::Insane);
00170 #else
00171 # define CEGUI_LOGINSANE( message )
00172 #endif
00173
00174 }
00175
00176 #if defined(_MSC_VER)
00177 # pragma warning(pop)
00178 #endif
00179
00180 #endif // end of guard _CEGUILogger_h_