00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef UTILS_LOG_H
00028 #define UTILS_LOG_H
00029
00030 #include <PVLE/Export.h>
00031 #include <osg/Notify>
00032
00033
00034
00035
00036
00037
00039 #ifdef _MSC_VER
00040
00041 #define __PVLE_METHOD__ __FUNCTION__
00042 #elif defined(__GNUC__)
00043
00044 #define __PVLE_METHOD__ __func__
00045 #else
00046
00047
00048
00049 #ifndef __METHOD__
00050 #define __METHOD__
00051 #endif
00052 #ifndef __FUNCTION__
00053 #define __FUNCTION__
00054 #endif
00055 #ifndef __func__
00056 #define __func__
00057 #endif
00058 #ifndef __FUNC__
00059 #define __FUNC__
00060 #endif
00061
00062 #include <boost/preprocessor/control/if.hpp>
00063 #include <boost/preprocessor/control/expr_if.hpp>
00064 #include <boost/preprocessor/facilities/is_empty.hpp>
00065
00066
00067 #define __PVLE_METHOD__ BOOST_PP_IF( BOOST_PP_IS_EMPTY(__METHOD__), \
00068 BOOST_PP_IF( BOOST_PP_IS_EMPTY(__FUNCTION__), \
00069 BOOST_PP_IF( BOOST_PP_IS_EMPTY(__func__), \
00070 BOOST_PP_IF( BOOST_PP_IS_EMPTY(__FUNC__), \
00071 "Unknown method", \
00072 __FUNC__), \
00073 __func__), \
00074 __FUNCTION__), \
00075 __METHOD__)
00076 #endif
00077
00078
00079
00080 #ifdef PVLE_NO_TRACE_INFO
00081 #define PVLE_TRACE_INFO ""
00082 #else
00083 #ifdef PVLE_LIGHT_TRACE_INFO
00084 #define PVLE_TRACE_INFO __PVLE_METHOD__ " : "
00085 #else
00086 #define PVLE_TRACE_INFO "File " << __FILE__ << " (line " << __LINE__ << ") " << __PVLE_METHOD__ " : "
00087 #endif
00088 #endif
00089
00090
00091
00092 #ifdef PVLE_FORCE_TRACE_LOG
00093 #define FORCED_LOG << PVLE_TRACE_INFO
00094 #else
00095 #define FORCED_LOG
00096 #endif
00097
00098
00099
00100 #define LOG_ALWAYS osg::notify(osg::ALWAYS) FORCED_LOG
00101 #define LOG_FATAL osg::notify(osg::FATAL) FORCED_LOG
00102 #define LOG_ERROR osg::notify(osg::FATAL) FORCED_LOG
00103 #define LOG_WARN osg::notify(osg::WARN) FORCED_LOG
00104 #define LOG_NOTICE osg::notify(osg::NOTICE) FORCED_LOG
00105 #define LOG_INFO osg::notify(osg::INFO) FORCED_LOG
00106 #define LOG_DEBUG_INFO osg::notify(osg::DEBUG_INFO) FORCED_LOG
00107 #define LOG_DEBUG_FP osg::notify(osg::DEBUG_FP) FORCED_LOG
00108
00109
00110
00111
00112
00113 #include <ostream>
00114
00115
00116 namespace osg {
00117 class Vec3f;
00118 class Vec4f;
00119 class Quat;
00120 class Matrixf;
00121 }
00122
00123 PVLE_EXPORT std::ostream& operator<<(std::ostream& stream, const osg::Vec3f& v);
00124 PVLE_EXPORT std::ostream& operator<<(std::ostream& stream, const osg::Vec4f& v);
00125 PVLE_EXPORT std::ostream& operator<<(std::ostream& stream, const osg::Quat& q);
00126 PVLE_EXPORT std::ostream& operator<<(std::ostream& stream, const osg::Matrixf& m);
00127
00128 #endif // UTILS_LOG_H