GraphicsAPI_2020C
DefaultLogger.hpp
Go to the documentation of this file.
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4 
5 Copyright (c) 2006-2017, assimp team
6 
7 All rights reserved.
8 
9 Redistribution and use of this software in source and binary forms,
10 with or without modification, are permitted provided that the
11 following conditions are met:
12 
13 * Redistributions of source code must retain the above
14  copyright notice, this list of conditions and the
15  following disclaimer.
16 
17 * Redistributions in binary form must reproduce the above
18  copyright notice, this list of conditions and the
19  following disclaimer in the documentation and/or other
20  materials provided with the distribution.
21 
22 * Neither the name of the assimp team, nor the names of its
23  contributors may be used to endorse or promote products
24  derived from this software without specific prior
25  written permission of the assimp team.
26 
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39 ----------------------------------------------------------------------
40 */
44 #ifndef INCLUDED_AI_DEFAULTLOGGER
45 #define INCLUDED_AI_DEFAULTLOGGER
46 
47 #include "Logger.hpp"
48 #include "LogStream.hpp"
49 #include "NullLogger.hpp"
50 #include <vector>
51 
52 namespace Assimp {
53 // ------------------------------------------------------------------------------------
54 class IOStream;
55 struct LogStreamInfo;
56 
58 #define ASSIMP_DEFAULT_LOG_NAME "AssimpLog.txt"
59 
60 // ------------------------------------------------------------------------------------
73 class ASSIMP_API DefaultLogger :
74  public Logger {
75 
76 public:
77 
78  // ----------------------------------------------------------------------
90  static Logger *create(const char* name = ASSIMP_DEFAULT_LOG_NAME,
91  LogSeverity severity = NORMAL,
92  unsigned int defStreams = aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE,
93  IOSystem* io = NULL);
94 
95  // ----------------------------------------------------------------------
103  static void set (Logger *logger);
104 
105  // ----------------------------------------------------------------------
109  static Logger *get();
110 
111  // ----------------------------------------------------------------------
116  static bool isNullLogger();
117 
118  // ----------------------------------------------------------------------
121  static void kill();
122 
123  // ----------------------------------------------------------------------
125  bool attachStream(LogStream *pStream,
126  unsigned int severity);
127 
128  // ----------------------------------------------------------------------
130  bool detatchStream(LogStream *pStream,
131  unsigned int severity);
132 
133 
134 private:
135 
136  // ----------------------------------------------------------------------
139  explicit DefaultLogger(LogSeverity severity);
140 
141  // ----------------------------------------------------------------------
143  ~DefaultLogger();
144 
145 private:
146 
148  void OnDebug(const char* message);
149 
151  void OnInfo(const char* message);
152 
154  void OnWarn(const char* message);
155 
157  void OnError(const char* message);
158 
159  // ----------------------------------------------------------------------
161  void WriteToStreams(const char* message, ErrorSeverity ErrorSev );
162 
163  // ----------------------------------------------------------------------
168  unsigned int GetThreadID();
169 
170 private:
171  // Aliases for stream container
172  typedef std::vector<LogStreamInfo*> StreamArray;
173  typedef std::vector<LogStreamInfo*>::iterator StreamIt;
174  typedef std::vector<LogStreamInfo*>::const_iterator ConstStreamIt;
175 
177  static Logger *m_pLogger;
178  static NullLogger s_pNullLogger;
179 
181  StreamArray m_StreamArray;
182 
183  bool noRepeatMsg;
184  char lastMsg[MAX_LOG_MESSAGE_LENGTH*2];
185  size_t lastLen;
186 };
187 // ------------------------------------------------------------------------------------
188 
189 } // Namespace Assimp
190 
191 #endif // !! INCLUDED_AI_DEFAULTLOGGER
Assimp&#39;s CPP-API and all internal APIs.
Definition: DefaultIOStream.h:51
CPP-API: Empty logging implementation.
Definition: NullLogger.hpp:58
ErrorSeverity
Description for severity of a log message.
Definition: Logger.hpp:87
CPP-API: Interface to the file system.
Definition: IOSystem.hpp:84
MSVC only: Stream the log the the debugger (this relies on OutputDebugString from the Win32 SDK) ...
Definition: types.h:443
Abstract base class &#39;Logger&#39;, base of the logging system.
LogSeverity
Log severity to describe the granularity of logging.
Definition: Logger.hpp:73
Abstract base class &#39;LogStream&#39;, representing an output log stream.
CPP-API: Abstract interface for log stream implementations.
Definition: LogStream.hpp:60
Stream the log to a file.
Definition: types.h:432
#define ASSIMP_DEFAULT_LOG_NAME
default name of logfile
Definition: DefaultLogger.hpp:58
CPP-API: Primary logging facility of Assimp.
Definition: DefaultLogger.hpp:73
Dummy logger.
CPP-API: Abstract interface for logger implementations.
Definition: Logger.hpp:62