chiark / gitweb /
treewide: use log_*_errno whenever %m is in the format string
[elogind.git] / src / udev / scsi_id / scsi_id.c
index 5511df882550b44313c987c7c64929acd38c2744..27adb09d1584b26d8fa3b23a986a6e74aec5dec7 100644 (file)
@@ -25,7 +25,6 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
-#include <syslog.h>
 #include <ctype.h>
 #include <getopt.h>
 #include <sys/stat.h>
@@ -55,7 +54,6 @@ static bool dev_specified = false;
 static char config_file[MAX_PATH_LEN] = "/etc/scsi_id.config";
 static enum page_code default_page_code = PAGE_UNSPECIFIED;
 static int sg_version = 4;
-static int debug = 0;
 static bool reformat_serial = false;
 static bool export = false;
 static char vendor_str[64];
@@ -65,14 +63,6 @@ static char model_enc_str[256];
 static char revision_str[16];
 static char type_str[16];
 
-_printf_(6,0)
-static void log_fn(struct udev *udev, int priority,
-                   const char *file, int line, const char *fn,
-                   const char *format, va_list args)
-{
-        vsyslog(priority, format, args);
-}
-
 static void set_type(const char *from, char *to, size_t len)
 {
         int type_num;
@@ -184,7 +174,7 @@ static int get_file_options(struct udev *udev,
                 if (errno == ENOENT)
                         return 1;
                 else {
-                        log_error("can't open %s: %m", config_file);
+                        log_error_errno(errno, "can't open %s: %m", config_file);
                         return -1;
                 }
         }
@@ -319,8 +309,8 @@ static void help(void) {
                "  -f,--config=                     location of config file\n"
                "  -p,--page=0x80|0x83|pre-spc3-83  SCSI page (0x80, 0x83, pre-spc3-83)\n"
                "  -s,--sg-version=3|4              use SGv3 or SGv4\n"
-               "  -b,--blacklisted                 threat device as blacklisted\n"
-               "  -g,--whitelisted                 threat device as whitelisted\n"
+               "  -b,--blacklisted                 treat device as blacklisted\n"
+               "  -g,--whitelisted                 treat device as whitelisted\n"
                "  -u,--replace-whitespace          replace all whitespace by underscores\n"
                "  -v,--verbose                     verbose logging\n"
                "     --version                     print version\n"
@@ -390,7 +380,9 @@ static int set_options(struct udev *udev,
                         break;
 
                 case 'v':
-                        debug++;
+                        log_set_target(LOG_TARGET_CONSOLE);
+                        log_set_max_level(LOG_DEBUG);
+                        log_open();
                         break;
 
                 case 'V':
@@ -583,13 +575,13 @@ int main(int argc, char **argv)
         int newargc;
         char **newargv = NULL;
 
+        log_parse_environment();
+        log_open();
+
         udev = udev_new();
         if (udev == NULL)
                 goto exit;
 
-        log_open();
-        udev_set_log_fn(udev, log_fn);
-
         /*
          * Get config file options.
          */