5 * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36 void info(const char *format, ...)
42 vsyslog(LOG_INFO, format, ap);
47 void error(const char *format, ...)
53 vsyslog(LOG_ERR, format, ap);
58 void obex_debug(const char *format, ...)
64 vsyslog(LOG_DEBUG, format, ap);
69 extern struct obex_debug_desc __start___debug[];
70 extern struct obex_debug_desc __stop___debug[];
72 static char **enabled = NULL;
74 static gboolean is_enabled(struct obex_debug_desc *desc)
81 for (i = 0; enabled[i] != NULL; i++) {
82 if (desc->name != NULL && g_pattern_match_simple(enabled[i],
85 if (desc->file != NULL && g_pattern_match_simple(enabled[i],
93 void __obex_log_enable_debug(void)
95 struct obex_debug_desc *desc;
97 for (desc = __start___debug; desc < __stop___debug; desc++)
98 desc->flags |= OBEX_DEBUG_FLAG_PRINT;
101 void __obex_log_init(const char *debug, int detach)
103 int option = LOG_NDELAY | LOG_PID;
104 struct obex_debug_desc *desc;
105 const char *name = NULL, *file = NULL;
108 enabled = g_strsplit_set(debug, ":, ", 0);
110 for (desc = __start___debug; desc < __stop___debug; desc++) {
111 if (file != NULL || name != NULL) {
112 if (g_strcmp0(desc->file, file) == 0) {
113 if (desc->name == NULL)
119 if (is_enabled(desc))
120 desc->flags |= OBEX_DEBUG_FLAG_PRINT;
124 option |= LOG_PERROR;
126 openlog("obexd", option, LOG_DAEMON);
128 info("OBEX daemon %s", VERSION);
131 void __obex_log_cleanup(void)