]> www.fi.muni.cz Git - evince.git/blob - libdocument/ev-debug.h
Add a profile mode available when debug is enabled. Add profilers in
[evince.git] / libdocument / ev-debug.h
1 /*
2  * ev-debug.h
3  * This file is part of Evince
4  *
5  * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
6  * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
7  * Copyright (C) 2002 - 2005 Paolo Maggi  
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, 
22  * Boston, MA 02111-1307, USA.
23  */
24  
25 /*
26  * Modified by the gedit Team, 1998-2005. See the AUTHORS file for a 
27  * list of people on the gedit Team.  
28  * See the ChangeLog files for a list of changes.
29  *
30  * $Id: gedit-debug.h 4809 2006-04-08 14:46:31Z pborelli $
31  */
32
33 /* Modified by Evince Team */
34
35 #ifndef __EV_DEBUG_H__
36 #define __EV_DEBUG_H__
37
38 #include <glib-object.h>
39
40 #define EV_GET_TYPE_NAME(instance) g_type_name_from_instance ((gpointer)instance)
41
42 #ifndef EV_ENABLE_DEBUG
43
44 #define ev_debug_init()
45 #define ev_debug_shutdown()
46 #if defined(G_HAVE_GNUC_VARARGS)
47 #define ev_debug_message(section, format, args...) G_STMT_START { } G_STMT_END
48 #define ev_profiler_start(format, args...) G_STMT_START { } G_STMT_END
49 #define ev_profiler_stop(format, args...) G_STMT_START { } G_STMT_END
50 #elif defined(G_HAVE_ISO_VARARGS)
51 #define ev_debug_message(...) G_STMT_START { } G_STMT_END
52 #define ev_profiler_start(...) G_STMT_START { } G_STMT_END
53 #define ev_profiler_stop(...) G_STMT_START { } G_STMT_END
54 #else /* no varargs macros */
55 static void ev_debug_message(EvDebugSection section, const gchar *file, gint line, const gchar *function, const gchar *format, ...) {}
56 static void ev_profiler_start(EvProfileSection section, const gchar *format, ...) {}
57 static void ev_profiler_stop(EvProfileSection section, const gchar *format, ...) {}
58 #endif
59
60 #else /* ENABLE_DEBUG */
61
62 G_BEGIN_DECLS
63
64 /*
65  * Set an environmental var of the same name to turn on
66  * debugging output. Setting EV_DEBUG will turn on all
67  * sections.
68  */
69 typedef enum {
70         EV_NO_DEBUG          = 0,
71         EV_DEBUG_JOBS        = 1 << 0
72 } EvDebugSection;
73
74 #define DEBUG_JOBS      EV_DEBUG_JOBS,    __FILE__, __LINE__, G_STRFUNC
75
76 /*
77  * Set an environmental var of the same name to turn on
78  * profiling. Setting EV_PROFILE will turn on all
79  * sections.
80  */
81 typedef enum {
82         EV_NO_PROFILE   = 0,
83         EV_PROFILE_JOBS = 1 << 0
84 } EvProfileSection;
85
86 void ev_debug_init     (void);
87 void ev_debug_shutdown (void);
88
89 void ev_debug_message  (EvDebugSection   section,
90                         const gchar     *file,
91                         gint             line,
92                         const gchar     *function,
93                         const gchar     *format, ...) G_GNUC_PRINTF(5, 6);
94 void ev_profiler_start (EvProfileSection section,
95                         const gchar     *format, ...) G_GNUC_PRINTF(2, 3);
96 void ev_profiler_stop  (EvProfileSection section,
97                         const gchar     *format, ...) G_GNUC_PRINTF(2, 3);
98
99 G_END_DECLS
100
101 #endif /* EV_ENABLE_DEBUG */
102 #endif /* __EV_DEBUG_H__ */