2001-10-22 05:27:40 +08:00
|
|
|
#include <osg/Notify>
|
2001-01-11 00:32:10 +08:00
|
|
|
#include <string>
|
|
|
|
|
2002-02-23 01:12:10 +08:00
|
|
|
using namespace std;
|
2002-02-03 19:35:24 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
osg::NotifySeverity osg::g_NotifyLevel = osg::NOTICE;
|
2002-03-27 07:52:52 +08:00
|
|
|
std::auto_ptr<ofstream> osg::g_NotifyNulStream;
|
2001-10-04 05:44:07 +08:00
|
|
|
bool osg::g_NotifyInit = false;
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
void osg::setNotifyLevel(osg::NotifySeverity severity)
|
2001-01-11 00:32:10 +08:00
|
|
|
{
|
2001-09-20 05:08:56 +08:00
|
|
|
osg::initNotifyLevel();
|
|
|
|
g_NotifyLevel = severity;
|
2001-01-11 00:32:10 +08:00
|
|
|
}
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
|
|
|
|
osg::NotifySeverity osg::getNotifyLevel()
|
2001-01-11 00:32:10 +08:00
|
|
|
{
|
2001-09-20 05:08:56 +08:00
|
|
|
osg::initNotifyLevel();
|
2001-01-11 00:32:10 +08:00
|
|
|
return g_NotifyLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
bool osg::initNotifyLevel()
|
2001-01-11 00:32:10 +08:00
|
|
|
{
|
2001-10-04 05:44:07 +08:00
|
|
|
if (g_NotifyInit) return true;
|
2001-09-20 05:08:56 +08:00
|
|
|
|
2001-10-04 05:44:07 +08:00
|
|
|
g_NotifyInit = true;
|
|
|
|
|
|
|
|
// set up global notify null stream for inline notify
|
2002-04-23 19:03:09 +08:00
|
|
|
#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__))
|
2002-04-08 16:22:27 +08:00
|
|
|
g_NotifyNulStream = std::auto_ptr<ofstream>(osgNew std::ofstream ("nul"));
|
2001-10-04 05:44:07 +08:00
|
|
|
#else
|
2002-03-27 07:52:52 +08:00
|
|
|
g_NotifyNulStream.reset(osgNew std::ofstream ("/dev/null"));
|
2001-10-04 05:44:07 +08:00
|
|
|
#endif
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
// g_NotifyLevel
|
|
|
|
// =============
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
g_NotifyLevel = osg::NOTICE; // Default value
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
char *OSGNOTIFYLEVEL=getenv("OSGNOTIFYLEVEL");
|
|
|
|
if(OSGNOTIFYLEVEL)
|
|
|
|
{
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
std::string stringOSGNOTIFYLEVEL(OSGNOTIFYLEVEL);
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
// Convert to upper case
|
|
|
|
for(std::string::iterator i=stringOSGNOTIFYLEVEL.begin();
|
|
|
|
i!=stringOSGNOTIFYLEVEL.end();
|
|
|
|
++i)
|
2001-01-11 00:32:10 +08:00
|
|
|
{
|
2001-09-20 05:08:56 +08:00
|
|
|
*i=toupper(*i);
|
2001-01-11 00:32:10 +08:00
|
|
|
}
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
if(stringOSGNOTIFYLEVEL.find("ALWAYS")!=std::string::npos) g_NotifyLevel=osg::ALWAYS;
|
|
|
|
else if(stringOSGNOTIFYLEVEL.find("FATAL")!=std::string::npos) g_NotifyLevel=osg::FATAL;
|
|
|
|
else if(stringOSGNOTIFYLEVEL.find("WARN")!=std::string::npos) g_NotifyLevel=osg::WARN;
|
|
|
|
else if(stringOSGNOTIFYLEVEL.find("NOTICE")!=std::string::npos) g_NotifyLevel=osg::NOTICE;
|
|
|
|
else if(stringOSGNOTIFYLEVEL.find("INFO")!=std::string::npos) g_NotifyLevel=osg::INFO;
|
|
|
|
else if(stringOSGNOTIFYLEVEL.find("DEBUG_INFO")!=std::string::npos) g_NotifyLevel=osg::DEBUG_INFO;
|
|
|
|
else if(stringOSGNOTIFYLEVEL.find("DEBUG_FP")!=std::string::npos) g_NotifyLevel=osg::DEBUG_FP;
|
|
|
|
else if(stringOSGNOTIFYLEVEL.find("DEBUG")!=std::string::npos) g_NotifyLevel=osg::DEBUG_INFO;
|
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
}
|
2001-09-20 05:08:56 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
}
|