44 #ifdef EV_ENABLE_DEBUG
45 static EvDebugSection ev_debug = EV_NO_DEBUG;
46 static EvProfileSection ev_profile = EV_NO_PROFILE;
47 static EvDebugBorders ev_debug_borders = EV_DEBUG_BORDER_NONE;
49 static GHashTable *timers = NULL;
54 const GDebugKey keys[] = {
55 {
"jobs", EV_DEBUG_JOBS },
56 {
"borders", EV_DEBUG_SHOW_BORDERS }
58 const GDebugKey border_keys[] = {
59 {
"chars", EV_DEBUG_BORDER_CHARS },
60 {
"links", EV_DEBUG_BORDER_LINKS },
61 {
"forms", EV_DEBUG_BORDER_FORMS },
62 {
"annots", EV_DEBUG_BORDER_ANNOTS },
63 {
"images", EV_DEBUG_BORDER_IMAGES },
64 {
"media", EV_DEBUG_BORDER_MEDIA },
65 {
"selections", EV_DEBUG_BORDER_SELECTIONS }
68 ev_debug = g_parse_debug_string (g_getenv (
"EV_DEBUG"), keys, G_N_ELEMENTS (keys));
69 if (ev_debug & EV_DEBUG_SHOW_BORDERS)
70 ev_debug_borders = g_parse_debug_string (g_getenv (
"EV_DEBUG_SHOW_BORDERS"),
71 border_keys, G_N_ELEMENTS (border_keys));
77 if (g_getenv (
"EV_PROFILE") != NULL) {
79 ev_profile = ~EV_NO_PROFILE;
81 if (g_getenv (
"EV_PROFILE_JOBS") != NULL)
82 ev_profile |= EV_PROFILE_JOBS;
86 timers = g_hash_table_new_full (g_str_hash,
88 (GDestroyNotify) g_free,
89 (GDestroyNotify) g_timer_destroy);
104 g_hash_table_destroy (timers);
113 const gchar *
function,
114 const gchar *format, ...)
116 if (G_UNLIKELY (ev_debug & section)) {
122 va_start (args, format);
123 msg = g_strdup_vprintf (format, args);
127 g_print (
"%s:%d (%s) %s\n", file, line,
function, msg ? msg :
"");
137 const gchar *format, ...)
139 if (G_UNLIKELY (ev_profile & section)) {
147 va_start (args, format);
148 name = g_strdup_vprintf (format, args);
151 timer = g_hash_table_lookup (timers, name);
153 timer = g_timer_new ();
154 g_hash_table_insert (timers, g_strdup (name), timer);
156 g_timer_start (timer);
163 const gchar *format, ...)
165 if (G_UNLIKELY (ev_profile & section)) {
174 va_start (args, format);
175 name = g_strdup_vprintf (format, args);
178 timer = g_hash_table_lookup (timers, name);
182 g_timer_stop (timer);
183 seconds = g_timer_elapsed (timer, NULL);
184 g_print (
"[ %s ] %f s elapsed\n", name, seconds);
190 ev_debug_get_debug_borders (
void)
192 return ev_debug_borders;