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 | #ifdef WANT_FRAME |
---|
40 | #define FRAME(...) GeoVis::logMessage(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) |
---|
41 | #else |
---|
42 | #define FRAME(...) |
---|
43 | #endif /*WANT_FRAME*/ |
---|
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 | |
---|
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 | |
---|
67 | } |
---|
68 | |
---|
69 | #endif |
---|