MyGUI  3.2.0
MyGUI_LogManager.h
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 #ifndef __MYGUI_LOG_MANAGER_H__
00023 #define __MYGUI_LOG_MANAGER_H__
00024 
00025 #include "MyGUI_Prerequest.h"
00026 #include "MyGUI_LogStream.h"
00027 #include "MyGUI_LogSource.h"
00028 #include "MyGUI_Diagnostic.h"
00029 #include <vector>
00030 
00031 namespace MyGUI
00032 {
00033 
00034     #define MYGUI_LOGGING(section, level, text) \
00035         MyGUI::LogManager::getInstance().log(section, MyGUI::LogLevel::level, MyGUI::LogStream() << text << MyGUI::LogStream::End(), __FILE__, __LINE__)
00036 
00037     class ConsoleLogListener;
00038     class FileLogListener;
00039     class LevelLogFilter;
00040 
00041     class MYGUI_EXPORT LogManager
00042     {
00043     public:
00044         LogManager();
00045         ~LogManager();
00046 
00047         static LogManager& getInstance();
00048         static LogManager* getInstancePtr();
00049 
00051         void flush();
00053         void log(const std::string& _section, LogLevel _level, const std::string& _message, const char* _file, int _line);
00054 
00056         void createDefaultSource(const std::string& _logname);
00057 
00061         void setSTDOutputEnabled(bool _value);
00063         bool getSTDOutputEnabled() const;
00064 
00066         void setLoggingLevel(LogLevel _value);
00068         LogLevel getLoggingLevel() const;
00069 
00071         void addLogSource(LogSource* _source);
00072 
00073     private:
00074         void close();
00075 
00076     private:
00077         static LogManager* msInstance;
00078 
00079         typedef std::vector<LogSource*> VectorLogSource;
00080         VectorLogSource mSources;
00081 
00082         ConsoleLogListener* mConsole;
00083         FileLogListener* mFile;
00084         LevelLogFilter* mFilter;
00085         LogSource* mDefaultSource;
00086 
00087         LogLevel mLevel;
00088         bool mConsoleEnable;
00089     };
00090 
00091 } // namespace MyGUI
00092 
00093 #endif // __MYGUI_LOG_MANAGER_H__