|
From: <ren...@us...> - 2008-01-31 19:56:16
|
Revision: 908
http://gmyth.svn.sourceforge.net/gmyth/?rev=908&view=rev
Author: renatofilho
Date: 2008-01-31 11:56:16 -0800 (Thu, 31 Jan 2008)
Log Message:
-----------
added gmyth-debug functions
Added Paths:
-----------
trunk/gmyth-dbus/src/gmyth_debug.c
trunk/gmyth-dbus/src/gmyth_debug.h
Added: trunk/gmyth-dbus/src/gmyth_debug.c
===================================================================
--- trunk/gmyth-dbus/src/gmyth_debug.c (rev 0)
+++ trunk/gmyth-dbus/src/gmyth_debug.c 2008-01-31 19:56:16 UTC (rev 908)
@@ -0,0 +1,58 @@
+/**
+ * GMyth Library
+ *
+ * @file gmyth/gmyth_debug.c
+ *
+ *
+ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
+ * @author Renato Filho <ren...@in...>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gmyth_debug.h"
+
+void
+gmyth_debug_real(const char *func,
+ const char *file, const int line, gboolean newline,
+ const char *format, ...)
+{
+ va_list args;
+ char buffer[1025];
+ char str_time[255];
+ time_t the_time;
+
+
+ if (g_getenv ("GMYTH-DEBUG"))
+ {
+ va_start(args, format);
+
+ g_vsnprintf(buffer, 1024, format, args);
+
+ va_end(args);
+
+ time(&the_time);
+ strftime(str_time, 254, "%H:%M:%S", localtime(&the_time));
+
+ g_printerr(newline ? "(%s) [%p] [%s] %s:%d: %s\n" :
+ "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self(), func,
+ file, line, buffer);
+ }
+}
Added: trunk/gmyth-dbus/src/gmyth_debug.h
===================================================================
--- trunk/gmyth-dbus/src/gmyth_debug.h (rev 0)
+++ trunk/gmyth-dbus/src/gmyth_debug.h 2008-01-31 19:56:16 UTC (rev 908)
@@ -0,0 +1,42 @@
+/**
+ * GMyth Library
+ *
+ * @file gmyth/gmyth_debug.h
+ *
+ *
+ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
+ * @author Renato Filho <ren...@in...>
+ *
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __GMYTH_DEBUG_H__
+#define __GMYTH_DEBUG_H__
+
+#include <stdarg.h>
+#include <glib.h>
+#include <time.h>
+
+G_BEGIN_DECLS
+#define gmyth_debug(...) gmyth_debug_real (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
+void
+gmyth_debug_real(const char *func,
+ const char *file, int line, gboolean newline,
+ const char *format, ...)
+G_GNUC_PRINTF(5, 6);
+
+G_END_DECLS
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|