summaryrefslogtreecommitdiff
path: root/logging.h
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-01-15 21:53:20 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:17 -0700
commit54988802b795328ceba29480611102902e88f572 (patch)
tree1bb53694614fe9ca088613368fcf6244618a0f16 /logging.h
parent5e4f123888a30bcc2a9fc256ec00315387b2d240 (diff)
[PATCH] add udev logging to info log
On Thu, Jan 15, 2004 at 05:14:16AM +0100, Kay Sievers wrote: > On Wed, Jan 14, 2004 at 01:10:43PM -0800, Greg KH wrote: > > On Wed, Jan 14, 2004 at 02:34:26PM -0600, Clay Haapala wrote: > > > On Wed, 14 Jan 2004, Chris Friesen spake thusly: > > > > > > > > Maybe for ones with a matching rule, you could print something like: > > > > > > > > > > > Is the act of printing/syslogging a rule in an of itself? > > > > No, as currently the only way stuff ends up in the syslog is if > > DEBUG=true is used on the build line. > > > > But it's sounding like we might want to change that... :) > > How about this in the syslog after connect/disconnect? > > Jan 15 05:07:45 pim udev[28007]: configured rule in '/etc/udev/udev.rules' at line 17 applied, 'video*' becomes 'video/webcam%n' > Jan 15 05:07:45 pim udev[28007]: creating device node '/udev/video/webcam0' > Jan 15 05:07:47 pim udev[28015]: removing device node '/udev/video/webcam0' Here is a slightly better version. I've created a logging.h file and moved the debug macros from udev.h in there. If you type: 'make' - you will get a binary that prints one or two lines to syslog if a device node is created or deleted 'make LOG=false' - you get a binary that prints asolutely nothing 'make DEBUG=true' - the same as today, it will print all debug lines
Diffstat (limited to 'logging.h')
-rw-r--r--logging.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/logging.h b/logging.h
new file mode 100644
index 0000000000..85016ad328
--- /dev/null
+++ b/logging.h
@@ -0,0 +1,60 @@
+/*
+ * udev.h
+ *
+ * Userspace devfs
+ *
+ * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef LOGGING_H
+#define LOGGING_H
+
+#ifdef LOG
+#include <syslog.h>
+#define info(format, arg...) \
+ do { \
+ log_message (LOG_INFO , format , ## arg); \
+ } while (0)
+#else
+ #define info(format, arg...) do { } while (0)
+#endif
+
+#ifdef DEBUG
+#define dbg(format, arg...) \
+ do { \
+ log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
+ } while (0)
+#else
+ #define dbg(format, arg...) do { } while (0)
+#endif
+
+/* Parser needs it's own debugging statement, we usually don't care about this at all */
+#ifdef DEBUG_PARSER
+#define dbg_parse(format, arg...) \
+ do { \
+ log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
+ } while (0)
+#else
+ #define dbg_parse(format, arg...) do { } while (0)
+#endif
+
+
+extern int log_message (int level, const char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
+
+#endif