1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2012 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.org/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <glib/gstdio.h>
28 #include <libmpd/debug_printf.h>
32 #define LOG_DOMAIN "Gmpc.Log"
35 static GLogLevelFlags global_log_level
= G_LOG_LEVEL_MESSAGE
;
37 static void gmpc_log_func(
38 const gchar
* log_domain
,
39 GLogLevelFlags log_level
,
40 const gchar
* message
,
43 if (log_level
<= global_log_level
)
45 g_log_default_handler(log_domain
, log_level
, message
, user_data
);
50 gboolean
log_add_filter(
51 const gchar
* option_name
,
56 if (value
== NULL
|| value
[0] == 0)
58 g_set_error(error
, 0, 0, "--log-filter requires a log domain as argument");
64 G_LOG_LEVEL_MASK
| G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION
,
65 g_log_default_handler
,
73 g_log_set_default_handler(gmpc_log_func
, NULL
);
77 void log_set_debug_level(int debug_level
)
80 * Set debug level, options are
83 * 2 = Error + Warning messages
90 global_log_level
= G_LOG_LEVEL_DEBUG
;
91 } else if (debug_level
== 2)
93 global_log_level
= G_LOG_LEVEL_INFO
;
95 debug_set_level(debug_level
);