Code

touch up logging infrastructure in preparation for interaction logging
authormental <mental@users.sourceforge.net>
Sun, 6 May 2007 21:30:21 +0000 (21:30 +0000)
committermental <mental@users.sourceforge.net>
Sun, 6 May 2007 21:30:21 +0000 (21:30 +0000)
src/debug/Makefile_insert
src/debug/event.h
src/debug/logger.h
src/debug/timestamp.cpp [new file with mode: 0644]
src/debug/timestamp.h [new file with mode: 0644]

index a8bf7761efc95538513d85b4a9b3cc4acc57750a..6205b5ca9ab79bbf074b08e1227ab0ac27ce7b6f 100644 (file)
@@ -12,5 +12,6 @@ debug_libinkdebug_a_SOURCES = \
        debug/gc-heap.h \
        debug/logger.cpp debug/logger.h \
        debug/simple-event.h \
-       debug/sysv-heap.cpp debug/sysv-heap.h
+       debug/sysv-heap.cpp debug/sysv-heap.h \
+        debug/timestamp.cpp debug/timestamp.h
 
index 54ac31476fe236143e727ce31025938112750010..2d91ea9f5b1a3954e61436319d8d0e1ac97abf1f 100644 (file)
@@ -31,6 +31,7 @@ public:
         REFCOUNT,
         EXTENSION,
         FINALIZERS,
+        INTERACTION,
         OTHER
     };
     enum { N_CATEGORIES=OTHER+1 };
index 61f9c27640281be9e5f325a35e8ae1eeec7858ba..1513c0ac65beab3e9fadec46ca3e935f9696d4fe 100644 (file)
@@ -142,6 +142,81 @@ public:
         }
     }
 
+    template <typename EventType>
+    inline static void write() {
+        start<EventType>();
+        finish();
+    }
+
+    template <typename EventType, typename A>
+    inline static void write(A const &a) {
+        start<EventType, A>(a);
+        finish();
+    }
+
+    template <typename EventType, typename A, typename B>
+    inline static void write(A const &a, B const &b) {
+        start<EventType, A, B>(a, b);
+        finish();
+    }
+
+    template <typename EventType, typename A, typename B, typename C>
+    inline static void write(A const &a, B const &b, C const &c) {
+        start<EventType, A, B, C>(a, b, c);
+        finish();
+    }
+
+    template <typename EventType, typename A, typename B,
+                                  typename C, typename D>
+    inline static void write(A const &a, B const &b, C const &c, D const &d) {
+        start<EventType, A, B, C, D>(a, b, c, d);
+        finish();
+    }
+
+    template <typename EventType, typename A, typename B,
+                                  typename C, typename D,
+                                  typename E>
+    inline static void write(A const &a, B const &b, C const &c,
+                             D const &d, E const &e)
+    {
+        start<EventType, A, B, C, D, E>(a, b, c, d, e);
+        finish();
+    }
+
+    template <typename EventType, typename A, typename B,
+                                  typename C, typename D,
+                                  typename E, typename F>
+    inline static void write(A const &a, B const &b, C const &c,
+                             D const &d, E const &e, F const &f)
+    {
+        start<EventType, A, B, C, D, E, F>(a, b, c, d, e, f);
+        finish();
+    }
+
+    template <typename EventType, typename A, typename B,
+                                  typename C, typename D,
+                                  typename E, typename F,
+                                  typename G>
+    inline static void write(A const &a, B const &b, C const &c,
+                             D const &d, E const &e, F const &f,
+                             G const &g)
+    {
+        start<EventType, A, B, C, D, E, F, G>(a, b, c, d, e, f, g);
+        finish();
+    }
+
+    template <typename EventType, typename A, typename B,
+                                  typename C, typename D,
+                                  typename E, typename F,
+                                  typename G, typename H>
+    inline static void write(A const &a, B const &b, C const &c,
+                             D const &d, E const &e, F const &f,
+                             G const &g, H const &h)
+    {
+        start<EventType, A, B, C, D, E, F, G, H>(a, b, c, d, e, f, g, h);
+        finish();
+    }
+
     static void shutdown();
 
 private:
diff --git a/src/debug/timestamp.cpp b/src/debug/timestamp.cpp
new file mode 100644 (file)
index 0000000..75447ff
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Inkscape::Debug::SimpleEvent - trivial implementation of Debug::Event
+ *
+ * Authors:
+ *   MenTaLguY <mental@rydia.net>
+ *
+ * Copyright (C) 2007 MenTaLguY
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+
+#include <glib/gtypes.h>
+#include <glib/gmain.h>
+#include <glibmm/ustring.h>
+#include "debug/simple-event.h"
+
+namespace Inkscape {
+
+namespace Debug {
+
+Util::ptr_shared<char> timestamp() {
+    Util::ptr_shared<char> result;
+    GTimeVal timestamp;
+    g_get_current_time(&timestamp);
+    gchar *value = g_strdup_printf("%d.%d", timestamp.tv_sec, timestamp.tv_usec);
+    result = Util::share_string(value);
+    g_free(value);
+    return result;
+}
+
+}
+
+}
+
+/*
+  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:encoding=utf-8:textwidth=99 :
diff --git a/src/debug/timestamp.h b/src/debug/timestamp.h
new file mode 100644 (file)
index 0000000..31eac35
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Inkscape::Debug::timestamp - timestamp strings
+ *
+ * Authors:
+ *   MenTaLguY <mental@rydia.net>
+ *
+ * Copyright (C) 2007 MenTaLguY
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef SEEN_INKSCAPE_DEBUG_TIMESTAMP_H
+#define SEEN_INKSCAPE_DEBUG_TIMESTAMP_H
+
+#include "util/share.h"
+
+namespace Inkscape {
+
+namespace Debug {
+
+Util::ptr_shared<char> timestamp();
+
+}
+
+}
+
+#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:encoding=utf-8:textwidth=99 :