1 /*
2 * Inkscape::Debug::Logger - debug logging facility
3 *
4 * Authors:
5 * MenTaLguY <mental@rydia.net>
6 *
7 * Copyright (C) 2005 MenTaLguY
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifndef SEEN_INKSCAPE_DEBUG_LOGGER_H
13 #define SEEN_INKSCAPE_DEBUG_LOGGER_H
15 #include "debug/event.h"
17 namespace Inkscape {
19 namespace Debug {
21 class Logger {
22 public:
23 static void init();
25 template <typename EventType>
26 inline static void start() {
27 if (_enabled) {
28 if (_category_mask[EventType::category()]) {
29 _start(EventType());
30 } else {
31 _skip();
32 }
33 }
34 }
36 template <typename EventType, typename A>
37 inline static void start(A const &a) {
38 if (_enabled) {
39 if (_category_mask[EventType::category()]) {
40 _start(EventType(a));
41 } else {
42 _skip();
43 }
44 }
45 }
47 template <typename EventType, typename A, typename B>
48 inline static void start(A const &a, B const &b) {
49 if (_enabled) {
50 if (_category_mask[EventType::category()]) {
51 _start(EventType(a, b));
52 } else {
53 _skip();
54 }
55 }
56 }
58 template <typename EventType, typename A, typename B, typename C>
59 inline static void start(A const &a, B const &b, C const &c) {
60 if (_enabled) {
61 if (_category_mask[EventType::category()]) {
62 _start(EventType(a, b, c));
63 } else {
64 _skip();
65 }
66 }
67 }
69 template <typename EventType, typename A, typename B,
70 typename C, typename D>
71 inline static void start(A const &a, B const &b, C const &c, D const &d) {
72 if (_enabled) {
73 if (_category_mask[EventType::category()]) {
74 _start(EventType(a, b, c, d));
75 } else {
76 _skip();
77 }
78 }
79 }
81 template <typename EventType, typename A, typename B, typename C,
82 typename D, typename E>
83 inline static void start(A const &a, B const &b, C const &c,
84 D const &d, E const &e)
85 {
86 if (_enabled) {
87 if (_category_mask[EventType::category()]) {
88 _start(EventType(a, b, c, d, e));
89 } else {
90 _skip();
91 }
92 }
93 }
95 template <typename EventType, typename A, typename B, typename C,
96 typename D, typename E, typename F>
97 inline static void start(A const &a, B const &b, C const &c,
98 D const &d, E const &e, F const &f)
99 {
100 if (_enabled) {
101 if (_category_mask[EventType::category()]) {
102 _start(EventType(a, b, c, d, e, f));
103 } else {
104 _skip();
105 }
106 }
107 }
109 template <typename EventType, typename A, typename B, typename C,
110 typename D, typename E, typename F,
111 typename G>
112 inline static void start(A const &a, B const &b, C const &c, D const &d,
113 E const &e, F const &f, G const &g)
114 {
115 if (_enabled) {
116 if (_category_mask[EventType::category()]) {
117 _start(EventType(a, b, c, d, e, f, g));
118 } else {
119 _skip();
120 }
121 }
122 }
124 template <typename EventType, typename A, typename B, typename C,
125 typename D, typename E, typename F,
126 typename G, typename H>
127 inline static void start(A const &a, B const &b, C const &c, D const &d,
128 E const &e, F const &f, G const &g, H const &h)
129 {
130 if (_enabled) {
131 if (_category_mask[EventType::category()]) {
132 _start(EventType(a, b, c, d, e, f, g, h));
133 } else {
134 _skip();
135 }
136 }
137 }
139 inline static void finish() {
140 if (_enabled) {
141 _finish();
142 }
143 }
145 static void shutdown();
147 private:
148 static bool _enabled;
150 static void _start(Event const &event);
151 static void _skip();
152 static void _finish();
154 static bool _category_mask[Event::N_CATEGORIES];
155 };
157 }
159 }
161 #endif
162 /*
163 Local Variables:
164 mode:c++
165 c-file-style:"stroustrup"
166 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
167 indent-tabs-mode:nil
168 fill-column:99
169 End:
170 */
171 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :