From ae482b5ca216978f0fdc1e5b89e9709c3ff8b06b Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sun, 27 Apr 2008 15:52:51 +0000 Subject: Merge branch 'ev-debug' into work svn path=/trunk/; revision=3025 --- (limited to 'libdocument') diff --git a/libdocument/Makefile.am b/libdocument/Makefile.am index 577c1c5..b225caa 100644 --- a/libdocument/Makefile.am +++ b/libdocument/Makefile.am @@ -14,6 +14,7 @@ libevbackend_la_LIBADD = $(LIB_LIBS) NOINST_H_FILES = \ ev-backend-marshalers.h \ ev-backends-manager.h \ + ev_debug.h \ ev-document-factory.h \ ev-module.h @@ -66,6 +67,7 @@ libevbackend_la_SOURCES= \ ev-document-transition.c \ ev-document-forms.c \ ev-form-field.c \ + ev-debug.c \ ev-file-exporter.c \ ev-file-helpers.c \ ev-module.c \ diff --git a/libdocument/ev-debug.c b/libdocument/ev-debug.c new file mode 100644 index 0000000..3806fd4 --- /dev/null +++ b/libdocument/ev-debug.c @@ -0,0 +1,85 @@ +/* + * ev-debug.c + * This file is part of Evince + * + * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence + * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi + * Copyright (C) 2002 - 2005 Paolo Maggi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU 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 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. + */ + +/* + * Modified by the gedit Team, 1998-2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id: gedit-debug.c 4809 2006-04-08 14:46:31Z pborelli $ + */ + +/* Modified by Evince Team */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "ev-debug.h" + +#ifdef EV_ENABLE_DEBUG +static EvDebugSection ev_debug = EV_NO_DEBUG; + +void +ev_debug_init () +{ + if (g_getenv ("EV_DEBUG") != NULL) { + /* enable all debugging */ + ev_debug = ~EV_NO_DEBUG; + return; + } + + if (g_getenv ("EV_DEBUG_JOBS") != NULL) + ev_debug |= EV_DEBUG_JOBS; +} + +void +ev_debug_message (EvDebugSection section, + const gchar *file, + gint line, + const gchar *function, + const gchar *format, ...) +{ + if (G_UNLIKELY (ev_debug & section)) { + gchar *msg = NULL; + + if (format) { + va_list args; + + va_start (args, format); + msg = g_strdup_vprintf (format, args); + va_end (args); + } + + g_print ("%s:%d (%s) %s\n", file, line, function, msg ? msg : ""); + + fflush (stdout); + + g_free (msg); + } +} + +#endif /* EV_ENABLE_DEBUG */ diff --git a/libdocument/ev-debug.h b/libdocument/ev-debug.h new file mode 100644 index 0000000..b025597 --- /dev/null +++ b/libdocument/ev-debug.h @@ -0,0 +1,72 @@ +/* + * ev-debug.h + * This file is part of Evince + * + * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence + * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi + * Copyright (C) 2002 - 2005 Paolo Maggi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU 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 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. + */ + +/* + * Modified by the gedit Team, 1998-2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id: gedit-debug.h 4809 2006-04-08 14:46:31Z pborelli $ + */ + +/* Modified by Evince Team */ + +#ifndef __EV_DEBUG_H__ +#define __EV_DEBUG_H__ + +#include + +#ifndef EV_ENABLE_DEBUG +#define ev_debug_init() +#define ev_debug_message(...) +#else + +G_BEGIN_DECLS + +/* + * Set an environmental var of the same name to turn on + * debugging output. Setting EV_DEBUG will turn on all + * sections. + */ +typedef enum { + EV_NO_DEBUG = 0, + EV_DEBUG_JOBS = 1 << 0 +} EvDebugSection; + + +#define DEBUG_JOBS EV_DEBUG_JOBS, __FILE__, __LINE__, G_STRFUNC + +void ev_debug_init (void); + +void ev_debug_message (EvDebugSection section, + const gchar *file, + gint line, + const gchar *function, + const gchar *format, ...) G_GNUC_PRINTF(5, 6); + + +G_END_DECLS + +#endif /* EV_ENABLE_DEBUG */ +#endif /* __EV_DEBUG_H__ */ diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c index 5e582d0..7bb86be 100644 --- a/libdocument/ev-document.c +++ b/libdocument/ev-document.c @@ -30,7 +30,6 @@ static void ev_document_class_init (gpointer g_class); GMutex *ev_doc_mutex = NULL; GMutex *ev_fc_mutex = NULL; -#define LOG(x) GType ev_document_get_type (void) { @@ -118,7 +117,7 @@ ev_document_load (EvDocument *document, { EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); gboolean retval; - LOG ("ev_document_load"); + retval = iface->load (document, uri, error); return retval; @@ -132,7 +131,6 @@ ev_document_save (EvDocument *document, EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); gboolean retval; - LOG ("ev_document_save"); retval = iface->save (document, uri, error); return retval; @@ -144,7 +142,6 @@ ev_document_get_n_pages (EvDocument *document) EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); gint retval; - LOG ("ev_document_get_n_pages"); retval = iface->get_n_pages (document); return retval; @@ -173,7 +170,6 @@ ev_document_get_page_size (EvDocument *document, { EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); - LOG ("ev_document_get_page_size"); iface->get_page_size (document, page, width, height); } @@ -183,7 +179,6 @@ ev_document_get_page_label (EvDocument *document, { EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); - LOG ("ev_document_get_page_label"); if (iface->get_page_label == NULL) return NULL; @@ -215,7 +210,6 @@ ev_document_get_attachments (EvDocument *document) EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); GList *retval; - LOG ("ev_document_get_attachments"); if (iface->get_attachments == NULL) return NULL; retval = iface->get_attachments (document); @@ -230,7 +224,6 @@ ev_document_render (EvDocument *document, EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); cairo_surface_t *retval; - LOG ("ev_document_render_pixbuf"); g_assert (iface->render); retval = iface->render (document, rc); -- cgit v0.9.1