Remove obsolete file.
[connman] / src / log.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
6  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <stdarg.h>
27 #include <syslog.h>
28
29 #include "connman.h"
30
31 static volatile gboolean debug_enabled = FALSE;
32
33 /**
34  * connman_info:
35  * @format: format string
36  * @Varargs: list of arguments
37  *
38  * Output general information
39  */
40 void connman_info(const char *format, ...)
41 {
42         va_list ap;
43
44         va_start(ap, format);
45
46         vsyslog(LOG_INFO, format, ap);
47
48         va_end(ap);
49 }
50
51 /**
52  * connman_error:
53  * @format: format string
54  * @varargs: list of arguments
55  *
56  * Output error messages
57  */
58 void connman_error(const char *format, ...)
59 {
60         va_list ap;
61
62         va_start(ap, format);
63
64         vsyslog(LOG_ERR, format, ap);
65
66         va_end(ap);
67 }
68
69 /**
70  * connman_debug:
71  * @format: format string
72  * @varargs: list of arguments
73  *
74  * Output debug message
75  *
76  * The actual output of the debug message is controlled via a command line
77  * switch. If not enabled, these messages will be ignored.
78  */
79 void connman_debug(const char *format, ...)
80 {
81         va_list ap;
82
83         if (debug_enabled == FALSE)
84                 return;
85
86         va_start(ap, format);
87
88         vsyslog(LOG_DEBUG, format, ap);
89
90         va_end(ap);
91 }
92
93 void __connman_toggle_debug(void)
94 {
95         if (debug_enabled == TRUE)
96                 debug_enabled = FALSE;
97         else
98                 debug_enabled = TRUE;
99 }
100
101 int __connman_log_init(gboolean detach, gboolean debug)
102 {
103         int option = LOG_NDELAY | LOG_PID;
104
105         if (detach == FALSE)
106                 option |= LOG_PERROR;
107
108         openlog("connmand", option, LOG_DAEMON);
109
110         syslog(LOG_INFO, "Connection Manager version %s", VERSION);
111
112         debug_enabled = debug;
113
114         return 0;
115 }
116
117 void __connman_log_cleanup(void)
118 {
119         syslog(LOG_INFO, "Exit");
120
121         closelog();
122 }
123
124 gboolean __connman_debug_enabled(void)
125 {
126         return debug_enabled;
127 }