cleanup debug level handover
[project/procd.git] / procd.c
diff --git a/procd.c b/procd.c
index a72912a..ad80284 100644 (file)
--- a/procd.c
+++ b/procd.c
@@ -32,7 +32,7 @@ static int usage(const char *prog)
                "Options:\n"
                "\t-s <path>\tPath to ubus socket\n"
                "\t-h <path>\trun as hotplug daemon\n"
-               "\td\t\tEnable debug messages\n"
+               "\t-d <level>\tEnable debug messages\n"
                "\n", prog);
        return 1;
 }
@@ -40,8 +40,14 @@ static int usage(const char *prog)
 int main(int argc, char **argv)
 {
        int ch;
+       char *dbglvl = getenv("DBGLVL");
 
-       while ((ch = getopt(argc, argv, "ds:h:")) != -1) {
+       if (dbglvl) {
+               debug = atoi(dbglvl);
+               unsetenv("DBGLVL");
+       }
+
+       while ((ch = getopt(argc, argv, "d:s:h:")) != -1) {
                switch (ch) {
                case 'h':
                        return hotplug_run(optarg);
@@ -49,7 +55,7 @@ int main(int argc, char **argv)
                        ubus_socket = optarg;
                        break;
                case 'd':
-                       debug++;
+                       debug = atoi(optarg);
                        break;
                default:
                        return usage(argv[0]);