summaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 8548249..e306935 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -240,6 +240,23 @@ is_debug_enabled(void)
}
+#if GLIB_CHECK_VERSION(2,61,2)
+static gint64
+get_relative_time(void)
+{
+ static unsigned long start_time;
+ gint64 tv;
+
+ if (G_UNLIKELY(!start_time)) {
+ glibtop_proc_time buf;
+ glibtop_get_proc_time(&buf, getpid());
+ start_time = buf.start_time;
+ }
+
+ tv = g_get_real_time ();
+ return tv - (gint64) start_time;
+}
+#else
static double
get_relative_time(void)
{
@@ -255,6 +272,7 @@ get_relative_time(void)
g_get_current_time(&tv);
return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
}
+#endif
static guint64
get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
@@ -296,8 +314,11 @@ procman_debug_real(const char *file, int line, const char *func,
msg = g_strdup_vprintf(format, args);
va_end(args);
+#if GLIB_CHECK_VERSION(2,61,2)
+ g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#else
g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
-
+#endif
g_free(msg);
}