00001 /*********************************************************************** 00002 filename: CEGUILogger.h 00003 created: 21/2/2004 00004 author: Paul D Turner 00005 00006 purpose: Defines interface for the Logger class 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _CEGUILogger_h_ 00031 #define _CEGUILogger_h_ 00032 00033 #include "CEGUIBase.h" 00034 #include "CEGUIString.h" 00035 #include <fstream> 00036 #include <sstream> 00037 #include <vector> 00038 #include <utility> 00039 #include "CEGUISingleton.h" 00040 00041 00042 #if defined(_MSC_VER) 00043 # pragma warning(push) 00044 # pragma warning(disable : 4275) 00045 # pragma warning(disable : 4251) 00046 #endif 00047 00048 00049 // Start of CEGUI namespace section 00050 namespace CEGUI 00051 { 00052 00057 enum LoggingLevel 00058 { 00059 Errors, 00060 Warnings, 00061 Standard, 00062 Informative, 00063 Insane 00064 }; 00065 00073 class CEGUIEXPORT Logger : public Singleton <Logger> 00074 { 00075 public: 00080 Logger(void); 00081 00085 virtual ~Logger(void); 00086 00087 00098 void setLoggingLevel(LoggingLevel level) {d_level = level;} 00099 00100 00108 LoggingLevel getLoggingLevel(void) const {return d_level;} 00109 00110 00124 virtual void logEvent(const String& message, LoggingLevel level = Standard) = 0; 00125 00143 virtual void setLogFilename(const String& filename, bool append = false) = 0; 00144 00145 protected: 00146 LoggingLevel d_level; 00147 00148 private: 00149 /************************************************************************* 00150 Copy constructor and assignment usage is denied. 00151 *************************************************************************/ 00152 Logger(const Logger& logger) : Singleton <Logger>() {} 00153 Logger& operator=(const Logger& logger) {return *this;} 00154 00155 }; 00156 00157 /************************************************************************* 00158 This macro is used for 'Insane' level logging so that those items are 00159 excluded from non-debug builds 00160 *************************************************************************/ 00161 #if defined(DEBUG) || defined (_DEBUG) 00162 # define CEGUI_LOGINSANE( message ) CEGUI::Logger::getSingleton().logEvent((message), CEGUI::Insane); 00163 #else 00164 # define CEGUI_LOGINSANE( message ) 00165 #endif 00166 00167 } // End of CEGUI namespace section 00168 00169 #if defined(_MSC_VER) 00170 # pragma warning(pop) 00171 #endif 00172 00173 #endif // end of guard _CEGUILogger_h_