5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
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 St, Fifth Floor, Boston, MA 02110-1301 USA
33 * @format: format string
34 * @Varargs: list of arguments
36 * Output general information
38 void connman_info(const char *format, ...)
44 vsyslog(LOG_INFO, format, ap);
51 * @format: format string
52 * @Varargs: list of arguments
54 * Output warning messages
56 void connman_warn(const char *format, ...)
62 vsyslog(LOG_WARNING, format, ap);
69 * @format: format string
70 * @varargs: list of arguments
72 * Output error messages
74 void connman_error(const char *format, ...)
80 vsyslog(LOG_ERR, format, ap);
87 * @format: format string
88 * @varargs: list of arguments
90 * Output debug message
92 void connman_debug(const char *format, ...)
98 vsyslog(LOG_DEBUG, format, ap);
103 extern struct connman_debug_desc __start___debug[];
104 extern struct connman_debug_desc __stop___debug[];
106 void __connman_debug_list_available(DBusMessageIter *iter, void *user_data)
108 struct connman_debug_desc *desc;
110 for (desc = __start___debug; desc < __stop___debug; desc++) {
111 if ((desc->flags & CONNMAN_DEBUG_FLAG_ALIAS) &&
113 dbus_message_iter_append_basic(iter,
114 DBUS_TYPE_STRING, &desc->name);
118 static gchar **enabled = NULL;
120 void __connman_debug_list_enabled(DBusMessageIter *iter, void *user_data)
127 for (i = 0; enabled[i] != NULL; i++)
128 dbus_message_iter_append_basic(iter,
129 DBUS_TYPE_STRING, &enabled[i]);
132 static connman_bool_t is_enabled(struct connman_debug_desc *desc)
139 for (i = 0; enabled[i] != NULL; i++) {
140 if (desc->name != NULL && g_pattern_match_simple(enabled[i],
143 if (desc->file != NULL && g_pattern_match_simple(enabled[i],
151 int __connman_log_init(const char *debug, connman_bool_t detach)
153 int option = LOG_NDELAY | LOG_PID;
154 struct connman_debug_desc *desc;
155 const char *name = NULL, *file = NULL;
158 enabled = g_strsplit_set(debug, ":, ", 0);
160 for (desc = __start___debug; desc < __stop___debug; desc++) {
161 if (desc->flags & CONNMAN_DEBUG_FLAG_ALIAS) {
167 if (file != NULL || name != NULL) {
168 if (g_strcmp0(desc->file, file) == 0) {
169 if (desc->name == NULL)
175 if (is_enabled(desc) == TRUE)
176 desc->flags |= CONNMAN_DEBUG_FLAG_PRINT;
180 option |= LOG_PERROR;
182 openlog("connmand", option, LOG_DAEMON);
184 syslog(LOG_INFO, "Connection Manager version %s", VERSION);
189 void __connman_log_cleanup(void)
191 syslog(LOG_INFO, "Exit");