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 | |
---|
11 | #include <cstring> |
---|
12 | #include <string> |
---|
13 | |
---|
14 | #include <syslog.h> |
---|
15 | |
---|
16 | #include <osg/NodeVisitor> |
---|
17 | |
---|
18 | namespace GeoVis { |
---|
19 | |
---|
20 | extern void logUserMessage(const char* format, ...); |
---|
21 | |
---|
22 | extern std::string getUserMessages(); |
---|
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*/ |
---|
39 | #define WARN(...) GeoVis::logMessage(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
---|
40 | #define INFO(...) GeoVis::logMessage(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
---|
41 | |
---|
42 | #define USER_ERROR(...) GeoVis::logUserMessage(__VA_ARGS__) |
---|
43 | |
---|
44 | class GraphPrintVisitor : public osg::NodeVisitor |
---|
45 | { |
---|
46 | public: |
---|
47 | GraphPrintVisitor() |
---|
48 | : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) |
---|
49 | {} |
---|
50 | |
---|
51 | virtual void apply(osg::Node& node) |
---|
52 | { |
---|
53 | char space[256]; |
---|
54 | size_t len = getNodePath().size(); |
---|
55 | memset(space, ' ', len); |
---|
56 | space[len] = '\0'; |
---|
57 | TRACE("%s%s (%s) %p", space, node.className(), node.getName().c_str(), &node); |
---|
58 | traverse(node); |
---|
59 | } |
---|
60 | }; |
---|
61 | |
---|
62 | } |
---|
63 | |
---|
64 | #endif |
---|