From 034563f2583320e9ed142ab3a86c8290cf29eaa6 Mon Sep 17 00:00:00 2001 From: mental Date: Sun, 6 May 2007 21:30:21 +0000 Subject: [PATCH] touch up logging infrastructure in preparation for interaction logging --- src/debug/Makefile_insert | 3 +- src/debug/event.h | 1 + src/debug/logger.h | 75 +++++++++++++++++++++++++++++++++++++++ src/debug/timestamp.cpp | 45 +++++++++++++++++++++++ src/debug/timestamp.h | 37 +++++++++++++++++++ 5 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 src/debug/timestamp.cpp create mode 100644 src/debug/timestamp.h diff --git a/src/debug/Makefile_insert b/src/debug/Makefile_insert index a8bf7761e..6205b5ca9 100644 --- a/src/debug/Makefile_insert +++ b/src/debug/Makefile_insert @@ -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 diff --git a/src/debug/event.h b/src/debug/event.h index 54ac31476..2d91ea9f5 100644 --- a/src/debug/event.h +++ b/src/debug/event.h @@ -31,6 +31,7 @@ public: REFCOUNT, EXTENSION, FINALIZERS, + INTERACTION, OTHER }; enum { N_CATEGORIES=OTHER+1 }; diff --git a/src/debug/logger.h b/src/debug/logger.h index 61f9c2764..1513c0ac6 100644 --- a/src/debug/logger.h +++ b/src/debug/logger.h @@ -142,6 +142,81 @@ public: } } + template + inline static void write() { + start(); + finish(); + } + + template + inline static void write(A const &a) { + start(a); + finish(); + } + + template + inline static void write(A const &a, B const &b) { + start(a, b); + finish(); + } + + template + inline static void write(A const &a, B const &b, C const &c) { + start(a, b, c); + finish(); + } + + template + inline static void write(A const &a, B const &b, C const &c, D const &d) { + start(a, b, c, d); + finish(); + } + + template + inline static void write(A const &a, B const &b, C const &c, + D const &d, E const &e) + { + start(a, b, c, d, e); + finish(); + } + + template + inline static void write(A const &a, B const &b, C const &c, + D const &d, E const &e, F const &f) + { + start(a, b, c, d, e, f); + finish(); + } + + template + 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(a, b, c, d, e, f, g); + finish(); + } + + template + 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(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 index 000000000..75447ff35 --- /dev/null +++ b/src/debug/timestamp.cpp @@ -0,0 +1,45 @@ +/* + * Inkscape::Debug::SimpleEvent - trivial implementation of Debug::Event + * + * Authors: + * MenTaLguY + * + * Copyright (C) 2007 MenTaLguY + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + + +#include +#include +#include +#include "debug/simple-event.h" + +namespace Inkscape { + +namespace Debug { + +Util::ptr_shared timestamp() { + Util::ptr_shared result; + GTimeVal timestamp; + g_get_current_time(×tamp); + 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 index 000000000..31eac35fd --- /dev/null +++ b/src/debug/timestamp.h @@ -0,0 +1,37 @@ +/* + * Inkscape::Debug::timestamp - timestamp strings + * + * Authors: + * MenTaLguY + * + * 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 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 : -- 2.30.2