[v2,1/4] Add log_level to the global options structure

Submitted by Adrian Reber on May 9, 2018, 5:16 p.m.

Details

Message ID 1525886210-10621-1-git-send-email-adrian@lisas.de
State New
Headers show

Patch hide | download patch | download mbox

diff --git a/criu/crtools.c b/criu/crtools.c
index 26ae8d1..27e54e0 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -80,6 +80,7 @@  void init_opts(void)
 	opts.timeout = DEFAULT_TIMEOUT;
 	opts.empty_ns = 0;
 	opts.status_fd = -1;
+	opts.log_level = DEFAULT_LOGLEVEL;
 }
 
 static int parse_join_ns(const char *ptr)
@@ -269,7 +270,6 @@  int main(int argc, char *argv[], char *envp[])
 	int opt = 0, idx;
 	int first_count = 1, second_count = 1;
 	int state = PARSING_GLOBAL_CONF;
-	int log_level = DEFAULT_LOGLEVEL;
 	char *imgs_dir = ".";
 
 #define BOOL_OPT(OPT_NAME, SAVE_TO) \
@@ -476,11 +476,11 @@  int main(int argc, char *argv[], char *envp[])
 			if (optarg) {
 				if (optarg[0] == 'v')
 					/* handle -vvvvv */
-					log_level += strlen(optarg) + 1;
+					opts.log_level += strlen(optarg) + 1;
 				else
-					log_level = atoi(optarg);
+					opts.log_level = atoi(optarg);
 			} else
-				log_level++;
+				opts.log_level++;
 			break;
 		case 1043: {
 			int fd;
@@ -772,7 +772,7 @@  int main(int argc, char *argv[], char *envp[])
 		return 1;
 	}
 
-	log_set_loglevel(log_level);
+	log_set_loglevel(opts.log_level);
 
 	if (log_init(opts.output))
 		return 1;
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
index f0e84c1..1365b2e 100644
--- a/criu/include/cr_options.h
+++ b/criu/include/cr_options.h
@@ -123,6 +123,7 @@  struct cr_options {
 	bool			orphan_pts_master;
 	int			check_only;
 	int			remote;
+	int			log_level;
 };
 
 extern struct cr_options opts;