vrshoot

view libs/assimp/LogAux.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
8 Redistribution and use of this software in source and binary forms,
9 with or without modification, are permitted provided that the
10 following conditions are met:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the
18 following disclaimer in the documentation and/or other
19 materials provided with the distribution.
21 * Neither the name of the assimp team, nor the names of its
22 contributors may be used to endorse or promote products
23 derived from this software without specific prior
24 written permission of the assimp team.
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ----------------------------------------------------------------------
39 */
41 /** @file LogAux.h
42 * @brief Common logging usage patterns for importer implementations
43 */
44 #ifndef INCLUDED_AI_LOGAUX_H
45 #define INCLUDED_AI_LOGAUX_H
47 #include "TinyFormatter.h"
49 namespace Assimp {
51 template <class TDeriving>
52 class LogFunctions
53 {
55 public:
57 // ------------------------------------------------------------------------------------------------
58 static void ThrowException(const std::string& msg)
59 {
60 throw DeadlyImportError(log_prefix+msg);
61 }
63 // ------------------------------------------------------------------------------------------------
64 static void LogWarn(const Formatter::format& message) {
65 if (!DefaultLogger::isNullLogger()) {
66 DefaultLogger::get()->warn(log_prefix+(std::string)message);
67 }
68 }
70 // ------------------------------------------------------------------------------------------------
71 static void LogError(const Formatter::format& message) {
72 if (!DefaultLogger::isNullLogger()) {
73 DefaultLogger::get()->error(log_prefix+(std::string)message);
74 }
75 }
77 // ------------------------------------------------------------------------------------------------
78 static void LogInfo(const Formatter::format& message) {
79 if (!DefaultLogger::isNullLogger()) {
80 DefaultLogger::get()->info(log_prefix+(std::string)message);
81 }
82 }
84 // ------------------------------------------------------------------------------------------------
85 static void LogDebug(const Formatter::format& message) {
86 if (!DefaultLogger::isNullLogger()) {
87 DefaultLogger::get()->debug(log_prefix+(std::string)message);
88 }
89 }
91 // https://sourceforge.net/tracker/?func=detail&atid=1067632&aid=3358562&group_id=226462
92 #if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
94 // ------------------------------------------------------------------------------------------------
95 static void LogWarn (const char* message) {
96 if (!DefaultLogger::isNullLogger()) {
97 LogWarn(Formatter::format(message));
98 }
99 }
101 // ------------------------------------------------------------------------------------------------
102 static void LogError (const char* message) {
103 if (!DefaultLogger::isNullLogger()) {
104 LogError(Formatter::format(message));
105 }
106 }
108 // ------------------------------------------------------------------------------------------------
109 static void LogInfo (const char* message) {
110 if (!DefaultLogger::isNullLogger()) {
111 LogInfo(Formatter::format(message));
112 }
113 }
115 // ------------------------------------------------------------------------------------------------
116 static void LogDebug (const char* message) {
117 if (!DefaultLogger::isNullLogger()) {
118 LogDebug(Formatter::format(message));
119 }
120 }
122 #endif
124 private:
126 static const std::string log_prefix;
128 };
130 } // ! Assimp
131 #endif