]> Dogcows Code - chaz/openbox/blob - openbox/debug.c
fix some more crashing. and make the max area selection more correct to avoid dead...
[chaz/openbox] / openbox / debug.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 debug.c for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "debug.h"
20
21 #include <glib.h>
22 #include <stdlib.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25
26 static gboolean show;
27
28 void ob_debug_show_output(gboolean enable)
29 {
30 show = enable;
31 }
32
33 void ob_debug(const gchar *a, ...)
34 {
35 va_list vl;
36
37 if (show) {
38 fprintf(stderr, "DEBUG: ");
39 va_start(vl, a);
40 vfprintf(stderr, a, vl);
41 va_end(vl);
42 }
43 }
44
45 static gboolean enabled_types[OB_DEBUG_TYPE_NUM] = {FALSE};
46
47 void ob_debug_enable(ObDebugType type, gboolean enable)
48 {
49 g_assert(type < OB_DEBUG_TYPE_NUM);
50 enabled_types[type] = enable;
51 }
52
53 void ob_debug_type(ObDebugType type, const gchar *a, ...)
54 {
55 va_list vl;
56
57 g_assert(type < OB_DEBUG_TYPE_NUM);
58
59 if (show && enabled_types[type]) {
60 switch (type) {
61 case OB_DEBUG_FOCUS:
62 fprintf(stderr, "FOCUS: ");
63 break;
64 case OB_DEBUG_APP_BUGS:
65 fprintf(stderr, "APPLICATION BUG: ");
66 break;
67 case OB_DEBUG_SM:
68 fprintf(stderr, "SESSION: ");
69 break;
70 default:
71 g_assert_not_reached();
72 }
73
74 va_start(vl, a);
75 vfprintf(stderr, a, vl);
76 va_end(vl);
77 }
78 }
This page took 0.035044 seconds and 4 git commands to generate.