chiark / gitweb /
[PATCH] make logging a config option
authorazarah@nosferatu.za.org <azarah@nosferatu.za.org>
Thu, 12 Feb 2004 03:42:51 +0000 (19:42 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:32:26 +0000 (21:32 -0700)
Once again, patch to make logging a config option.

Reason for this (since you asked for it):
 - In our setup it is easy (although still annoying) .. just edit the
   ebuild, add logging support (or remove it) and rebuild.  For say a
   binary distro, having the logging is useful for debugging some
   times, but its more a once of, or rare thing, as you do not add or
   change config files every day.  Sure, we can have logging by
   default, but many do not want ~300 lines of extra debugging in their
   logs is not pleasant, and they will complain.  Rebuilding the
   package for that binary package (given the users it is targeted to)
   is usually not within most users grasp.

Makefile
etc/udev/udev.conf.in
logging.h
udev.h
udev_config.c

index 97c6ca63bd1e4adb901dcda82d6732fc04ef60ca..ebcb2815c806736d79d194ccdab70c0a19f18c0c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -239,6 +239,7 @@ udev_version.h:
        @echo \#define UDEV_CONFIG_FILE \"$(configdir)\udev.conf\" >> $@
        @echo \#define UDEV_RULES_FILE  \"$(configdir)\udev.rules\" >> $@
        @echo \#define UDEV_PERMISSION_FILE     \"$(configdir)\udev.permissions\" >> $@
+       @echo \#define UDEV_LOG_DEFAULT \"yes\" >> $@
        @echo \#define UDEV_BIN         \"$(DESTDIR)$(sbindir)/udev\" >> $@
        @echo \#define UDEVD_BIN        \"$(DESTDIR)$(sbindir)/udevd\" >> $@
 
index f9a60ab3c8886b122d85d56e4aacc40fc4dde3c1..3e73bedbf5c864a8e66dc6212b68f8c4cf73bc43 100644 (file)
@@ -29,3 +29,6 @@ default_owner="root"
 #                 explicit match in the permissions file
 default_group="root"
 
+# udev_log - set to "yes" if you want logging, else "no"
+udev_log="yes"
+
index 485209adf3a553595207e9fc4150df3ed77fe334..5ae228b139fa778379ac0e03011b44adfd1bd60c 100644 (file)
--- a/logging.h
+++ b/logging.h
@@ -34,6 +34,9 @@
 #include <unistd.h>
 #include <syslog.h>
 
+#include "udev.h"
+#include "udev_version.h"
+
 #undef info
 #define info(format, arg...)                                                           \
        do {                                                                            \
@@ -63,6 +66,9 @@ static inline void log_message (int level, const char *format, ...)
 {
        va_list args;
 
+       if (0 != strncmp(udev_log_str, UDEV_LOG_DEFAULT, BOOL_SIZE))
+               return;
+
        va_start(args, format);
        vsyslog(level, format, args);
        va_end(args);
diff --git a/udev.h b/udev.h
index f854a183d3e49121781ef90f356fa971794c4f6e..8b3f305d34effbe8d654a5094be98e00182a86ea 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -32,6 +32,8 @@
 #define OWNER_SIZE     30
 #define GROUP_SIZE     30
 #define MODE_SIZE      8
+#define BOOL_SIZE      5       /* 'yes', 'no' and possibly 'true' or 'false'
+                                  in future */
 
 struct udevice {
        char name[NAME_SIZE];
@@ -72,5 +74,6 @@ extern char udev_rules_filename[PATH_MAX+NAME_MAX];
 extern char default_mode_str[MODE_SIZE];
 extern char default_owner_str[OWNER_SIZE];
 extern char default_group_str[GROUP_SIZE];
+extern char udev_log_str[BOOL_SIZE];
 
 #endif
index 6d39d294e1dba8843e93549eeae839f943fbad6c..ec38272bc595aea3d84e1bbf4d9c03ba26c542d8 100644 (file)
@@ -48,6 +48,7 @@ char udev_config_filename[PATH_MAX+NAME_MAX];
 char default_mode_str[MODE_SIZE];
 char default_owner_str[OWNER_SIZE];
 char default_group_str[GROUP_SIZE];
+char udev_log_str[BOOL_SIZE];
 
 
 static void init_variables(void)
@@ -60,6 +61,7 @@ static void init_variables(void)
        strfieldcpy(udev_config_filename, UDEV_CONFIG_FILE);
        strfieldcpy(udev_rules_filename, UDEV_RULES_FILE);
        strfieldcpy(udev_permissions_filename, UDEV_PERMISSION_FILE);
+       strfieldcpy(udev_log_str, UDEV_LOG_DEFAULT);
 }
 
 #define set_var(_name, _var)                           \
@@ -156,6 +158,7 @@ static int parse_config_file(void)
                set_var("default_mode", default_mode_str);
                set_var("default_owner", default_owner_str);
                set_var("default_group", default_group_str);
+               set_var("udev_log", udev_log_str);
        }
        dbg_parse("%s:%d:%Zd: error parsing '%s'", udev_config_filename,
                  lineno, temp - line, temp);
@@ -191,6 +194,7 @@ static void get_dirs(void)
        dbg_parse("udev_db_filename = %s", udev_db_filename);
        dbg_parse("udev_rules_filename = %s", udev_rules_filename);
        dbg_parse("udev_permissions_filename = %s", udev_permissions_filename);
+       dbg_parse("udev_log_str = %s", udev_log_str);
        parse_config_file();
 
        dbg_parse("udev_root = %s", udev_root);
@@ -198,6 +202,7 @@ static void get_dirs(void)
        dbg_parse("udev_db_filename = %s", udev_db_filename);
        dbg_parse("udev_rules_filename = %s", udev_rules_filename);
        dbg_parse("udev_permissions_filename = %s", udev_permissions_filename);
+       dbg_parse("udev_log_str = %s", udev_log_str);
 }
 
 void udev_init_config(void)