OpenVDB  3.0.0
logging.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2014 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30 
31 #ifndef OPENVDB_UTIL_LOGGING_HAS_BEEN_INCLUDED
32 #define OPENVDB_UTIL_LOGGING_HAS_BEEN_INCLUDED
33 
34 #ifndef OPENVDB_USE_LOG4CPLUS
35 
37 #define OPENVDB_LOG_INFO(message)
38 #define OPENVDB_LOG_WARN(message) do { std::cerr << message << std::endl; } while (0);
40 #define OPENVDB_LOG_ERROR(message) do { std::cerr << message << std::endl; } while (0);
42 #define OPENVDB_LOG_FATAL(message) do { std::cerr << message << std::endl; } while (0);
44 #define OPENVDB_LOG_DEBUG(message)
46 #define OPENVDB_LOG_DEBUG_RUNTIME(message)
49 
50 #else // ifdef OPENVDB_USE_LOG4CPLUS
51 
52 #include <log4cplus/logger.h>
53 #include <log4cplus/loglevel.h>
54 #include <sstream>
55 
56 #define OPENVDB_LOG(level, message) \
57  do { \
58  log4cplus::Logger _log = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main")); \
59  if (_log.isEnabledFor(log4cplus::level##_LOG_LEVEL)) { \
60  std::ostringstream _buf; \
61  _buf << message; \
62  _log.forcedLog(log4cplus::level##_LOG_LEVEL, _buf.str(), __FILE__, __LINE__); \
63  } \
64  } while (0);
65 
66 #define OPENVDB_LOG_INFO(message) OPENVDB_LOG(INFO, message)
67 #define OPENVDB_LOG_WARN(message) OPENVDB_LOG(WARN, message)
68 #define OPENVDB_LOG_ERROR(message) OPENVDB_LOG(ERROR, message)
69 #define OPENVDB_LOG_FATAL(message) OPENVDB_LOG(FATAL, message)
70 #ifdef DEBUG
71 #define OPENVDB_LOG_DEBUG(message) OPENVDB_LOG(DEBUG, message)
72 #else
73 #define OPENVDB_LOG_DEBUG(message)
74 #endif
75 #define OPENVDB_LOG_DEBUG_RUNTIME(message) OPENVDB_LOG(DEBUG, message)
76 
77 #endif // OPENVDB_USE_LOG4CPLUS
78 
79 #endif // OPENVDB_UTIL_LOGGING_HAS_BEEN_INCLUDED
80 
81 // Copyright (c) 2012-2014 DreamWorks Animation LLC
82 // All rights reserved. This software is distributed under the
83 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )