[lxc-devel] [PATCH] allow setting/getting lxc.loglevel and lxc.logfile via set_config_item/get_config_item API calls

S.Çağlar Onur caglar at 10ur.org
Sat Nov 2 04:43:55 UTC 2013


Signed-off-by: S.Çağlar Onur <caglar at 10ur.org>
---
 src/lxc/log.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/lxc/log.c b/src/lxc/log.c
index 0946e44..e5eb04f 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -295,13 +295,13 @@ extern int lxc_log_init(const char *name, const char *file,
 	}
 
 	if (priority) {
-		lxc_loglevel_specified = 1;
-		lxc_priority = lxc_log_priority_to_int(priority);
-
 		if (lxc_priority == LXC_LOG_PRIORITY_NOTSET) {
 			ERROR("invalid log priority %s", priority);
 			return -1;
 		}
+
+		lxc_loglevel_specified = 1;
+		lxc_priority = lxc_log_priority_to_int(priority);
 	}
 
 	lxc_log_category_lxc.priority = lxc_priority;
@@ -314,9 +314,9 @@ extern int lxc_log_init(const char *name, const char *file,
 		lxc_log_set_prefix(prefix);
 
 	if (file) {
-		lxc_logfile_specified = 1;
 		if (strcmp(file, "none") == 0)
 			return 0;
+		lxc_logfile_specified = 1;
 		ret = __lxc_log_set_file(file, 1);
 	} else {
 		ret = -1;
@@ -362,6 +362,7 @@ extern int lxc_log_set_level(int level)
 		ERROR("invalid log priority %d", level);
 		return -1;
 	}
+	lxc_loglevel_specified = 1;
 	lxc_log_category_lxc.priority = level;
 	return 0;
 }
@@ -390,6 +391,7 @@ extern int lxc_log_set_file(const char *fname)
 {
 	if (lxc_logfile_specified)
 		return 0;
+	lxc_logfile_specified = 1;
 	return __lxc_log_set_file(fname, 0);
 }
 
-- 
1.8.3.2





More information about the lxc-devel mailing list