2003-01-22 00:45:36 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2001-10-04 23:12:57 +08:00
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
#ifndef OSG_NOTIFY
|
|
|
|
#define OSG_NOTIFY 1
|
|
|
|
|
|
|
|
#include <osg/Export>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
2002-03-27 07:52:52 +08:00
|
|
|
#include <memory>
|
2001-01-11 00:32:10 +08:00
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
/** Range of notify levels from DEBUG_FP through to FATAL, ALWAYS
|
|
|
|
* is reserved for forcing the absorption of all messages. The
|
|
|
|
* keywords are also used verbatim when specified by the environmental
|
|
|
|
* variable OSGNOTIFYLEVEL. See documentation on osg::notify() for
|
|
|
|
* further details.
|
|
|
|
*/
|
2001-01-11 00:32:10 +08:00
|
|
|
enum NotifySeverity {
|
|
|
|
ALWAYS=0,
|
|
|
|
FATAL=1,
|
|
|
|
WARN=2,
|
|
|
|
NOTICE=3,
|
|
|
|
INFO=4,
|
2001-09-20 05:08:56 +08:00
|
|
|
DEBUG_INFO=5,
|
|
|
|
DEBUG_FP=6
|
2001-01-11 00:32:10 +08:00
|
|
|
};
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
/** global notify level. */
|
2002-12-05 20:43:08 +08:00
|
|
|
//extern SG_EXPORT NotifySeverity g_NotifyLevel;
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-10-04 05:44:07 +08:00
|
|
|
/** global notify nul stream. added for Mac OSX */
|
2002-12-05 20:43:08 +08:00
|
|
|
//extern SG_EXPORT std::auto_ptr<std::ofstream> g_NotifyNulStream;
|
2001-10-04 05:44:07 +08:00
|
|
|
|
|
|
|
/** global notify nul stream. added for Mac OSX */
|
2002-12-05 20:43:08 +08:00
|
|
|
//extern SG_EXPORT bool g_NotifyInit;
|
2001-10-04 05:44:07 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
/** set the notify level, overriding the default or value set by
|
|
|
|
* the environmental variable OSGNOTIFYLEVEL.
|
|
|
|
*/
|
2002-12-05 20:43:08 +08:00
|
|
|
extern SG_EXPORT void setNotifyLevel(NotifySeverity severity);
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
/** get the notify level. */
|
2002-12-05 20:43:08 +08:00
|
|
|
extern SG_EXPORT NotifySeverity getNotifyLevel();
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
/** initialize notify level. */
|
2002-12-05 20:43:08 +08:00
|
|
|
extern SG_EXPORT bool initNotifyLevel();
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
/** notify messaging function for providing fatal through to verbose
|
|
|
|
* debugging messages. Level of messages sent to the console can
|
|
|
|
* be controlled by setting the NotifyLevel either within your
|
|
|
|
* application or via the an environmental variable. For instance
|
|
|
|
* setenv OSGNOTIFYLEVEL DEBUG (for tsh), export OSGNOTIFYLEVEL=DEBUG
|
|
|
|
* (for bourne shell) or set OSGNOTIFYLEVEL=DEBUG (for Windows) all
|
|
|
|
* set tell the osg to redirect all debugging and more important messages
|
|
|
|
* to the console (useful for debugging :-) setting ALWAYS will force
|
|
|
|
* all messages to be absorbed, which might be appropriate for final
|
|
|
|
* applications. Default NotifyLevel is NOTICE. Check the enum
|
|
|
|
* NotifySeverity for full range of possibilities. To use the notify
|
|
|
|
* with your code simply use the notify function as a normal file
|
|
|
|
* stream (like cout) i.e osg::notify(osg::DEBUG) << "Hello Bugs!"<<endl;
|
|
|
|
*/
|
2001-10-04 05:44:07 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// PJA MAC OSX 30-09-01
|
|
|
|
// previous implementation was causing Mac OSX to misbehave. This version
|
|
|
|
// places less stress on compiler and runs on Mac
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2002-12-05 20:43:08 +08:00
|
|
|
extern SG_EXPORT std::ostream& notify(const NotifySeverity severity);
|
2002-06-12 02:41:57 +08:00
|
|
|
// {
|
|
|
|
// static bool initilized = false;
|
|
|
|
// if (!initilized) initilized = initNotifyLevel();
|
|
|
|
//
|
|
|
|
// if (severity<=g_NotifyLevel)
|
|
|
|
// {
|
|
|
|
// if (severity<=osg::WARN) return std::cerr;
|
|
|
|
// else return std::cout;
|
|
|
|
// }
|
|
|
|
// cout << "doing a notify to null stream "<<osg::g_NotifyLevel<<" "<<osg::g_NotifyNulStream.get()<<" "<<osg::g_NotifyInit<<endl;
|
|
|
|
// //if (osg::g_NotifyNulStream.get()==0L) abort();
|
|
|
|
// return std::cout;
|
|
|
|
// //return *osg::g_NotifyNulStream;
|
|
|
|
// }
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2001-12-15 05:49:04 +08:00
|
|
|
inline std::ostream& notify(void) { return notify(osg::INFO); }
|
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2001-01-11 00:32:10 +08:00
|
|
|
|
|
|
|
#endif
|