3 * neard - Near Field Communication manager
5 * Copyright (C) 2011 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 void near_info(const char *format, ...)
37 vsyslog(LOG_INFO, format, ap);
42 void near_warn(const char *format, ...)
48 vsyslog(LOG_WARNING, format, ap);
53 void near_error(const char *format, ...)
59 vsyslog(LOG_ERR, format, ap);
64 void near_debug(const char *format, ...)
70 vsyslog(LOG_DEBUG, format, ap);
75 extern struct near_debug_desc __start___debug[];
76 extern struct near_debug_desc __stop___debug[];
78 static gchar **enabled = NULL;
80 static bool is_enabled(struct near_debug_desc *desc)
87 for (i = 0; enabled[i]; i++) {
88 if (desc->name && g_pattern_match_simple(enabled[i],
91 if (desc->file && g_pattern_match_simple(enabled[i],
99 int __near_log_init(const char *debug, gboolean detach)
101 int option = LOG_NDELAY | LOG_PID;
102 struct near_debug_desc *desc;
103 const char *name = NULL, *file = NULL;
106 enabled = g_strsplit_set(debug, ":, ", 0);
108 for (desc = __start___debug; desc < __stop___debug; desc++) {
110 if (g_strcmp0(desc->file, file) == 0) {
117 if (is_enabled(desc))
118 desc->flags |= NEAR_DEBUG_FLAG_PRINT;
122 option |= LOG_PERROR;
124 openlog("neard", option, LOG_DAEMON);
126 syslog(LOG_INFO, "NEAR daemon version %s", VERSION);
131 void __near_log_cleanup(void)
133 syslog(LOG_INFO, "Exit");