Mercurial > projects > xinhibit-applet
annotate xia-debug.c @ 1:bdab58c3db61 version-1
Add de translation
author | Guido Berhoerster <guido+xinhibit-applet@berhoerster.name> |
---|---|
date | Sat, 27 Apr 2013 09:38:02 +0200 |
parents | 9a16bf50daba |
children | a47449b807b2 |
rev | line source |
---|---|
0
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
1 /* |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
2 * Copyright (C) 2013 Guido Berhoerster <guido+xinhibit-applet@berhoerster.name> |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
3 * |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
4 * Permission is hereby granted, free of charge, to any person obtaining |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
5 * a copy of this software and associated documentation files (the |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
6 * "Software"), to deal in the Software without restriction, including |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
7 * without limitation the rights to use, copy, modify, merge, publish, |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
8 * distribute, sublicense, and/or sell copies of the Software, and to |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
9 * permit persons to whom the Software is furnished to do so, subject to |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
10 * the following conditions: |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
11 * |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
12 * The above copyright notice and this permission notice shall be included |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
13 * in all copies or substantial portions of the Software. |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
14 * |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
22 */ |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
23 |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
24 #include <string.h> |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
25 #include <stdarg.h> |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
26 #include <glib.h> |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
27 |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
28 #include "xia-debug.h" |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
29 |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
30 static void |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
31 dummy_log_handler(const gchar *log_domain, GLogLevelFlags log_level, |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
32 const gchar *message, gpointer data) |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
33 { |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
34 /* Swallow all messages */ |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
35 } |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
36 |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
37 void |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
38 xia_debug_init(gboolean debug_mode) |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
39 { |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
40 /* |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
41 * glib >= 2.32 only shows debug messages if G_MESSAGES_DEBUG contains |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
42 * the log domain or "all", earlier glib version always show debugging |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
43 * output |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
44 */ |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
45 #if GLIB_CHECK_VERSION(2, 32, 0) |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
46 const gchar *debug_env; |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
47 gchar *debug_env_new; |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
48 |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
49 if (debug_mode) { |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
50 debug_env = g_getenv("G_MESSAGES_DEBUG"); |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
51 |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
52 if (debug_env == NULL) { |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
53 g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, TRUE); |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
54 } else if (strstr(debug_env, G_LOG_DOMAIN) == NULL) { |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
55 debug_env_new = g_strdup_printf("%s %s", debug_env, |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
56 G_LOG_DOMAIN); |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
57 g_setenv("G_MESSAGES_DEBUG", debug_env_new, TRUE); |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
58 g_free(debug_env_new); |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
59 } |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
60 } |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
61 #else |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
62 if (!debug_mode) { |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
63 g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
64 dummy_log_handler, NULL); |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
65 } |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
66 #endif /* GLIB_CHECK_VERSION (2,32,0) */ |
9a16bf50daba
Initial revision
Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
parents:
diff
changeset
|
67 } |