/src/ogre/OgreMain/include/OgreLogManager.h
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | |
29 | | #ifndef __LogManager_H__ |
30 | | #define __LogManager_H__ |
31 | | |
32 | | #include "OgrePrerequisites.h" |
33 | | |
34 | | #include "OgreLog.h" |
35 | | #include "OgreSingleton.h" |
36 | | #include "OgreHeaderPrefix.h" |
37 | | |
38 | | namespace Ogre |
39 | | { |
40 | | /** \addtogroup Core |
41 | | * @{ |
42 | | */ |
43 | | /** \addtogroup General |
44 | | * @{ |
45 | | */ |
46 | | /** The log manager handles the creation and retrieval of logs for the |
47 | | application. |
48 | | |
49 | | This class will create new log files and will retrieve instances |
50 | | of existing ones. Other classes wishing to log output can either |
51 | | create a fresh log or retrieve an existing one to output to. |
52 | | One log is the default log, and is the one written to when the |
53 | | logging methods of this class are called. |
54 | | @par |
55 | | By default, Root will instantiate a LogManager (which becomes the |
56 | | Singleton instance) on construction, and will create a default log |
57 | | based on the Root construction parameters. If you want more control, |
58 | | for example redirecting log output right from the start or suppressing |
59 | | debug output, you need to create a LogManager yourself before creating |
60 | | a Root instance, then create a default log. Root will detect that |
61 | | you've created one yourself and won't create one of its own, thus |
62 | | using all your logging preferences from the first instance. |
63 | | */ |
64 | | class _OgreExport LogManager : public Singleton<LogManager>, public LogAlloc |
65 | | { |
66 | | private: |
67 | | typedef std::map<String, Log*> LogList; |
68 | | |
69 | | /// A list of all the logs the manager can access |
70 | | LogList mLogs; |
71 | | |
72 | | /// The default log to which output is done |
73 | | Log* mDefaultLog; |
74 | | |
75 | | public: |
76 | | OGRE_AUTO_MUTEX; // public to allow external locking |
77 | | |
78 | | LogManager(); |
79 | | ~LogManager(); |
80 | | |
81 | | /** Creates a new log with the given name. |
82 | | @param |
83 | | name The name to give the log e.g. 'Ogre.log' |
84 | | @param |
85 | | defaultLog If true, this is the default log output will be |
86 | | sent to if the generic logging methods on this class are |
87 | | used. The first log created is always the default log unless |
88 | | this parameter is set. |
89 | | @param |
90 | | debuggerOutput If true, output to this log will also be |
91 | | routed to the debugger's output window. |
92 | | @param |
93 | | suppressFileOutput If true, this is a logical rather than a physical |
94 | | log and no file output will be written. If you do this you should |
95 | | register a LogListener so log output is not lost. |
96 | | */ |
97 | | Log* createLog( const String& name, bool defaultLog = false, bool debuggerOutput = true, |
98 | | bool suppressFileOutput = false); |
99 | | |
100 | | /** Retrieves a log managed by this class. |
101 | | */ |
102 | | Log* getLog( const String& name); |
103 | | |
104 | | /** Returns a pointer to the default log. |
105 | | */ |
106 | | Log* getDefaultLog(); |
107 | | |
108 | | /** Closes and removes a named log. */ |
109 | | void destroyLog(const String& name); |
110 | | /** Closes and removes a log. */ |
111 | | void destroyLog(Log* log); |
112 | | |
113 | | /** Sets the passed in log as the default log. |
114 | | @return The previous default log. |
115 | | */ |
116 | | Log* setDefaultLog(Log* newLog); |
117 | | |
118 | | /** Log a message to the default log. |
119 | | */ |
120 | | void logMessage( const String& message, LogMessageLevel lml = LML_NORMAL, |
121 | | bool maskDebug = false); |
122 | | |
123 | | /// @overload |
124 | | void logError(const String& message, bool maskDebug = false ); |
125 | | /// @overload |
126 | | void logWarning(const String& message, bool maskDebug = false ); |
127 | | |
128 | | /** Log a message to the default log (signature for backward compatibility). |
129 | | */ |
130 | | void logMessage( LogMessageLevel lml, const String& message, |
131 | 0 | bool maskDebug = false) { logMessage(message, lml, maskDebug); } |
132 | | |
133 | | /** Get a stream on the default log. */ |
134 | | Log::Stream stream(LogMessageLevel lml = LML_NORMAL, |
135 | | bool maskDebug = false); |
136 | | |
137 | | /// @deprecated use setMinLogLevel() |
138 | | OGRE_DEPRECATED void setLogDetail(LoggingLevel ll); |
139 | | /// sets the minimal #LogMessageLevel for the default log |
140 | | void setMinLogLevel(LogMessageLevel lml); |
141 | | /// @copydoc Singleton::getSingleton() |
142 | | static LogManager& getSingleton(void); |
143 | | /// @copydoc Singleton::getSingleton() |
144 | | static LogManager* getSingletonPtr(void); |
145 | | |
146 | | }; |
147 | | |
148 | | |
149 | | /** @} */ |
150 | | /** @} */ |
151 | | } |
152 | | |
153 | | #include "OgreHeaderSuffix.h" |
154 | | |
155 | | #endif |