Browse Source

logtoserial can now take strings

K. Lange 2 years ago
parent
commit
8c3d99da3c
1 changed files with 15 additions and 1 deletions
  1. 15 1
      modules/serial.c

+ 15 - 1
modules/serial.c

@@ -203,7 +203,21 @@ static int serial_mount_devices(void) {
 	char * c;
 	if ((c = args_value("logtoserial"))) {
 		debug_file = ttyS0;
-		debug_level = atoi(c);
+		if (!strcmp(c,"INFO") || !strcmp(c,"info")) {
+			debug_level = INFO;
+		} else if (!strcmp(c,"NOTICE") || !strcmp(c,"notice")) {
+			debug_level = NOTICE;
+		} else if (!strcmp(c,"WARNING") || !strcmp(c,"warning")) {
+			debug_level = WARNING;
+		} else if (!strcmp(c,"ERROR") || !strcmp(c,"error")) {
+			debug_level = ERROR;
+		} else if (!strcmp(c,"CRITICAL") || !strcmp(c,"critical")) {
+			debug_level = CRITICAL;
+		} else if (!strcmp(c,"INSANE") || !strcmp(c,"insane")) {
+			debug_level = INSANE;
+		} else {
+			debug_level = atoi(c);
+		}
 		debug_print(NOTICE, "Serial logging enabled at level %d.", debug_level);
 	}