Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreLogManager.h @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 6.5 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29
30#ifndef __LogManager_H__
31#define __LogManager_H__
32
33#include "OgrePrerequisites.h"
34
35#include "OgreLog.h"
36#include "OgreSingleton.h"
37#include "OgreString.h"
38
39namespace Ogre
40{
41    /** The log manager handles the creation and retrieval of logs for the
42        application.
43        @remarks
44            This class will create new log files and will retrieve instances
45            of existing ones. Other classes wishing to log output can either
46            create a fresh log or retrieve an existing one to output to.
47            One log is the default log, and is the one written to when the
48            logging methods of this class are called.
49                @par
50                        By default, Root will instantiate a LogManager (which becomes the
51                        Singleton instance) on construction, and will create a default log
52                        based on the Root construction parameters. If you want more control,
53                        for example redirecting log output right from the start or suppressing
54                        debug output, you need to create a LogManager yourself before creating
55                        a Root instance, then create a default log. Root will detect that
56                        you've created one yourself and won't create one of its own, thus
57                        using all your logging preferences from the first instance.
58    */
59    class _OgreExport LogManager : public Singleton<LogManager>
60    {
61        protected:
62        typedef std::map<String, Log*, std::less<String> >      LogList;
63
64        /// A list of all the logs the manager can access
65        LogList mLogs;
66
67        /// The default log to which output is done
68        Log* mDefaultLog;
69
70    public:
71                OGRE_AUTO_MUTEX // public to allow external locking
72
73        LogManager();
74        ~LogManager();
75
76        /** Creates a new log with the given name.
77            @param
78                name The name to give the log e.g. 'Ogre.log'
79            @param
80                defaultLog If true, this is the default log output will be
81                sent to if the generic logging methods on this class are
82                used. The first log created is always the default log unless
83                this parameter is set.
84            @param
85                debuggerOutput If true, output to this log will also be
86                routed to the debugger's output window.
87            @param
88                suppressFileOutput If true, this is a logical rather than a physical
89                                log and no file output will be written. If you do this you should
90                                register a LogListener so log output is not lost.
91        */
92        Log* createLog( const String& name, bool defaultLog = false, bool debuggerOutput = true, 
93                        bool suppressFileOutput = false);
94
95        /** Retrieves a log managed by this class.
96        */
97        Log* getLog( const String& name);
98
99        /** Returns a pointer to the default log.
100        */
101        Log* getDefaultLog();
102
103                /** Closes and removes a named log. */
104                void destroyLog(const String& name);
105                /** Closes and removes a log. */
106                void destroyLog(Log* log);
107
108                /** Sets the passed in log as the default log.
109        @returns The previous default log.
110        */
111        Log* setDefaultLog(Log* newLog);
112
113        /** Log a message to the default log.
114        */
115        void logMessage( const String& message, LogMessageLevel lml = LML_NORMAL, 
116            bool maskDebug = false);
117
118        /** Log a message to the default log (signature for backward compatibility).
119        */
120        void logMessage( LogMessageLevel lml, const String& message, 
121                        bool maskDebug = false) { logMessage(message, lml, maskDebug); }
122
123                /** Sets the level of detail of the default log.
124        */
125        void setLogDetail(LoggingLevel ll);
126        /** Override standard Singleton retrieval.
127        @remarks
128        Why do we do this? Well, it's because the Singleton
129        implementation is in a .h file, which means it gets compiled
130        into anybody who includes it. This is needed for the
131        Singleton template to work, but we actually only want it
132        compiled into the implementation of the class based on the
133        Singleton, not all of them. If we don't change this, we get
134        link errors when trying to use the Singleton-based class from
135        an outside dll.
136        @par
137        This method just delegates to the template version anyway,
138        but the implementation stays in this single compilation unit,
139        preventing link errors.
140        */
141        static LogManager& getSingleton(void);
142        /** Override standard Singleton retrieval.
143        @remarks
144        Why do we do this? Well, it's because the Singleton
145        implementation is in a .h file, which means it gets compiled
146        into anybody who includes it. This is needed for the
147        Singleton template to work, but we actually only want it
148        compiled into the implementation of the class based on the
149        Singleton, not all of them. If we don't change this, we get
150        link errors when trying to use the Singleton-based class from
151        an outside dll.
152        @par
153        This method just delegates to the template version anyway,
154        but the implementation stays in this single compilation unit,
155        preventing link errors.
156        */
157        static LogManager* getSingletonPtr(void);
158
159    };
160
161}
162
163#endif
Note: See TracBrowser for help on using the repository browser.