]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/debug.c
add shortcuts for text rendering. it underlines the first character in the string...
[mikachu/openbox.git] / 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         va_start(vl, a);
39         vfprintf(stderr, a, vl);
40         va_end(vl);
41     }
42 }
43
44 static gboolean enabled_types[OB_DEBUG_TYPE_NUM] = {FALSE};
45
46 void ob_debug_enable(ObDebugType type, gboolean enable)
47 {
48     g_assert(type < OB_DEBUG_TYPE_NUM);
49     enabled_types[type] = enable;
50 }
51
52 void ob_debug_type(ObDebugType type, const gchar *a, ...)
53 {
54     va_list vl;
55
56     g_assert(type < OB_DEBUG_TYPE_NUM);
57
58     if (show && enabled_types[type]) {
59         va_start(vl, a);
60         vfprintf(stderr, a, vl);
61         va_end(vl);
62     }
63 }