1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 Copyright (C) 2008 Sébastien Granjoux <seb.sfo@free.fr>
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "anjuta-debug.h"
27 static gchar
**anjuta_log_modules
= NULL
;
30 anjuta_log_handler (const char *log_domain
,
31 GLogLevelFlags log_level
,
36 if (log_level
& G_LOG_LEVEL_DEBUG
)
38 /* Filter only debugging messages */
42 /* Do not display anything if anjuta_log_modules is empty
43 * (happens only in non debugging mode) */
44 if (anjuta_log_modules
== NULL
) return;
46 /* log_domain can be NULL*/
47 domain
= (log_domain
== NULL
) || (*log_domain
== '\0') ? "NULL" : log_domain
;
49 for (i
= 0; anjuta_log_modules
[i
] != NULL
; i
++)
51 if (strcmp(domain
, anjuta_log_modules
[i
]) == 0)
54 g_log_default_handler (log_domain
, log_level
, message
, user_data
);
62 g_log_default_handler (log_domain
, log_level
, message
, user_data
);
68 * Initialize filtering of debug messages.
71 anjuta_debug_init (void)
76 log
= g_getenv ("ANJUTA_LOG_DOMAINS");
79 anjuta_log_modules
= g_strsplit_set (log
, ": ", -1);
81 if (anjuta_log_modules
!= NULL
)
85 for (i
= 0; anjuta_log_modules
[i
] != NULL
; i
++)
87 if (strcmp("all", anjuta_log_modules
[i
]) == 0)
97 if ((anjuta_log_modules
!= NULL
) && (anjuta_log_modules
[0] != NULL
) && !all
)
99 /* Display selected message in debugging mode if environment
100 * variable is no set to all */
104 /* Display selected message in non debugging mode if the
105 * environment variable doesn't exist or if not set to all */
107 g_log_set_default_handler (anjuta_log_handler
, NULL
);