summaryrefslogtreecommitdiffstats
path: root/src/debug/logger.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
commitc853ffb5b2f75f5a889ed2e3ef89b818a736e87a (patch)
tree7d13a0883bb7936b84d6ecdd7bc332b41ed04bee /src/debug/logger.h
parentInitial commit. (diff)
downloadinkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.tar.xz
inkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.zip
Adding upstream version 1.3+ds.upstream/1.3+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/debug/logger.h')
-rw-r--r--src/debug/logger.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/debug/logger.h b/src/debug/logger.h
new file mode 100644
index 0000000..572ff0d
--- /dev/null
+++ b/src/debug/logger.h
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Inkscape::Debug::Logger - debug logging facility
+ *
+ * Authors:
+ * MenTaLguY <mental@rydia.net>
+ *
+ * Copyright (C) 2005 MenTaLguY
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#ifndef SEEN_INKSCAPE_DEBUG_LOGGER_H
+#define SEEN_INKSCAPE_DEBUG_LOGGER_H
+
+#include "debug/event.h"
+
+namespace Inkscape {
+
+namespace Debug {
+
+class Logger {
+public:
+ static void init();
+
+ template <typename EventType, typename... Args>
+ inline static void start(Args&&... args) {
+ if (_enabled) {
+ if (_category_mask[EventType::category()]) {
+ _start(EventType(std::forward<Args>(args)...));
+ } else {
+ _skip();
+ }
+ }
+ }
+
+ inline static void finish() {
+ if (_enabled) {
+ _finish();
+ }
+ }
+
+ template <typename EventType, typename... Args>
+ inline static void write(Args&&... args) {
+ start<EventType, Args...>(std::forward<Args>(args)...);
+ finish();
+ }
+
+ static void shutdown();
+
+private:
+ static bool _enabled;
+
+ static void _start(Event const &event);
+ static void _skip();
+ static void _finish();
+
+ static bool _category_mask[Event::N_CATEGORIES];
+};
+
+}
+
+}
+
+#endif
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :