[3998] | 1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
| 2 | /* |
---|
| 3 | * Copyright (C) 2004-2013 HUBzero Foundation, LLC |
---|
| 4 | * |
---|
| 5 | * Author: George A. Howlett <gah@purdue.edu> |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #ifndef GEOVIS_TRACE_H |
---|
| 9 | #define GEOVIS_TRACE_H |
---|
| 10 | |
---|
[4655] | 11 | #include <cstring> |
---|
[4422] | 12 | #include <string> |
---|
| 13 | |
---|
[3998] | 14 | #include <syslog.h> |
---|
| 15 | |
---|
[4655] | 16 | #include <osg/NodeVisitor> |
---|
| 17 | |
---|
[3998] | 18 | namespace GeoVis { |
---|
| 19 | |
---|
| 20 | extern void logUserMessage(const char* format, ...); |
---|
| 21 | |
---|
[4422] | 22 | extern std::string getUserMessages(); |
---|
[3998] | 23 | |
---|
| 24 | extern void clearUserMessages(); |
---|
| 25 | |
---|
| 26 | extern void initLog(); |
---|
| 27 | |
---|
| 28 | extern void closeLog(); |
---|
| 29 | |
---|
| 30 | extern void logMessage(int priority, const char *funcname, const char *fileName, |
---|
| 31 | int lineNum, const char* format, ...); |
---|
| 32 | |
---|
| 33 | #define ERROR(...) GeoVis::logMessage(LOG_ERR, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
---|
| 34 | #ifdef WANT_TRACE |
---|
| 35 | #define TRACE(...) GeoVis::logMessage(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
---|
| 36 | #else |
---|
| 37 | #define TRACE(...) |
---|
| 38 | #endif /*WANT_TRACE*/ |
---|
[5915] | 39 | #ifdef WANT_FRAME |
---|
| 40 | #define FRAME(...) GeoVis::logMessage(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
---|
| 41 | #else |
---|
| 42 | #define FRAME(...) |
---|
| 43 | #endif /*WANT_FRAME*/ |
---|
[3998] | 44 | #define WARN(...) GeoVis::logMessage(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
---|
| 45 | #define INFO(...) GeoVis::logMessage(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
---|
| 46 | |
---|
| 47 | #define USER_ERROR(...) GeoVis::logUserMessage(__VA_ARGS__) |
---|
| 48 | |
---|
[4655] | 49 | class GraphPrintVisitor : public osg::NodeVisitor |
---|
| 50 | { |
---|
| 51 | public: |
---|
| 52 | GraphPrintVisitor() |
---|
| 53 | : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) |
---|
| 54 | {} |
---|
| 55 | |
---|
| 56 | virtual void apply(osg::Node& node) |
---|
| 57 | { |
---|
| 58 | char space[256]; |
---|
| 59 | size_t len = getNodePath().size(); |
---|
| 60 | memset(space, ' ', len); |
---|
| 61 | space[len] = '\0'; |
---|
| 62 | TRACE("%s%s (%s) %p", space, node.className(), node.getName().c_str(), &node); |
---|
| 63 | traverse(node); |
---|
| 64 | } |
---|
| 65 | }; |
---|
| 66 | |
---|
[3998] | 67 | } |
---|
| 68 | |
---|
| 69 | #endif |
---|