Browse Source

core: added --debug=val command line parameter

- set the value for debug global parameter from command line, allows
negative values corresponding to L_XYZ levels
- alternative to -d which operated by incresing debug level starting
from 0
Daniel-Constantin Mierla 5 years ago
parent
commit
9b6ec0a491
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/main.c

+ 12 - 1
src/main.c

@@ -169,7 +169,8 @@ Options:\n\
     -b nr        Maximum receive buffer size which will not be exceeded by\n\
                   auto-probing procedure even if  OS allows\n\
     -c           Check configuration file for syntax errors\n\
-    -d           Debugging mode (multiple -d increase the level)\n\
+    -d           Debugging level control (multiple -d to increase the level from 0)\n\
+    --debug=val  Debugging level value\n\
     -D           Control how daemonize is done:\n\
                   -D..do not fork (almost) anyway;\n\
                   -DD..do not daemonize creator;\n\
@@ -1931,6 +1932,7 @@ int main(int argc, char** argv)
 		{"loadmodule",  required_argument, 0, KARGOPTVAL + 5},
 		{"modparam",    required_argument, 0, KARGOPTVAL + 6},
 		{"log-engine",  required_argument, 0, KARGOPTVAL + 7},
+		{"debug",       required_argument, 0, KARGOPTVAL + 8},
 		{0, 0, 0, 0 }
 	};
 
@@ -1992,6 +1994,14 @@ int main(int argc, char** argv)
 			case KARGOPTVAL+7:
 					ksr_slog_init(optarg);
 					break;
+			case KARGOPTVAL+8:
+					debug_flag = 1;
+					default_core_cfg.debug=(int)strtol(optarg, &tmp, 10);
+					if ((tmp==0) || (*tmp)){
+						LM_ERR("bad debug level value: %s\n", optarg);
+						goto error;
+					}
+					break;
 
 			default:
 					if (c == 'h' || (optarg && strcmp(optarg, "-h") == 0)) {
@@ -2153,6 +2163,7 @@ int main(int argc, char** argv)
 			case KARGOPTVAL+5:
 			case KARGOPTVAL+6:
 			case KARGOPTVAL+7:
+			case KARGOPTVAL+8:
 					break;
 
 			/* long options */