5 * Copyright (C) 2007-2009 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
31 static volatile gboolean debug_enabled = FALSE;
35 * @format: format string
36 * @Varargs: list of arguments
38 * Output general information
40 void connman_info(const char *format, ...)
46 vsyslog(LOG_INFO, format, ap);
53 * @format: format string
54 * @Varargs: list of arguments
56 * Output warning messages
58 void connman_warn(const char *format, ...)
64 vsyslog(LOG_WARNING, format, ap);
71 * @format: format string
72 * @varargs: list of arguments
74 * Output error messages
76 void connman_error(const char *format, ...)
82 vsyslog(LOG_ERR, format, ap);
89 * @format: format string
90 * @varargs: list of arguments
92 * Output debug message
94 * The actual output of the debug message is controlled via a command line
95 * switch. If not enabled, these messages will be ignored.
97 void connman_debug(const char *format, ...)
101 if (debug_enabled == FALSE)
104 va_start(ap, format);
106 vsyslog(LOG_DEBUG, format, ap);
111 void __connman_toggle_debug(void)
113 if (debug_enabled == TRUE) {
114 connman_info("Disabling debug output");
115 debug_enabled = FALSE;
117 connman_info("Enabling debug output");
118 debug_enabled = TRUE;
122 int __connman_log_init(gboolean detach, gboolean debug)
124 int option = LOG_NDELAY | LOG_PID;
127 option |= LOG_PERROR;
129 openlog("connmand", option, LOG_DAEMON);
131 syslog(LOG_INFO, "Connection Manager version %s", VERSION);
134 __connman_toggle_debug();
139 void __connman_log_cleanup(void)
141 syslog(LOG_INFO, "Exit");
146 gboolean __connman_debug_enabled(void)
148 return debug_enabled;