147 lines
5.2 KiB
Diff
147 lines
5.2 KiB
Diff
From 171cb932bbbbfc5816ceb65223f1d5e733c79d8e Mon Sep 17 00:00:00 2001
|
|
From: Li Feng <lifeng2221dd1@zoho.com.cn>
|
|
Date: Sat, 30 Jan 2021 10:38:11 +0800
|
|
Subject: [PATCH 19/53] log: use the same function to init log in
|
|
export/pause/resume
|
|
|
|
Signed-off-by: Li Feng <lifeng2221dd1@zoho.com.cn>
|
|
---
|
|
src/cmd/isula/extend/export.c | 19 +++++++++----------
|
|
src/cmd/isula/extend/pause.c | 20 +++++++++-----------
|
|
src/cmd/isula/extend/resume.c | 17 +++++++----------
|
|
3 files changed, 25 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/src/cmd/isula/extend/export.c b/src/cmd/isula/extend/export.c
|
|
index 476cf775..ea9b9c11 100644
|
|
--- a/src/cmd/isula/extend/export.c
|
|
+++ b/src/cmd/isula/extend/export.c
|
|
@@ -76,15 +76,7 @@ int cmd_export_main(int argc, const char **argv)
|
|
char file[PATH_MAX] = { 0 };
|
|
struct isula_libutils_log_config lconf = { 0 };
|
|
|
|
- lconf.name = argv[0];
|
|
- lconf.quiet = true;
|
|
- lconf.driver = "stdout";
|
|
- lconf.file = NULL;
|
|
- lconf.priority = "ERROR";
|
|
- if (isula_libutils_log_enable(&lconf)) {
|
|
- COMMAND_ERROR("Export: log init failed");
|
|
- exit(ECOMMON);
|
|
- }
|
|
+ isula_libutils_default_log_config(argv[0], &lconf);
|
|
|
|
command_t cmd;
|
|
if (client_arguments_init(&g_cmd_export_args)) {
|
|
@@ -92,7 +84,9 @@ int cmd_export_main(int argc, const char **argv)
|
|
exit(ECOMMON);
|
|
}
|
|
g_cmd_export_args.progname = argv[0];
|
|
- struct command_option options[] = { COMMON_OPTIONS(g_cmd_export_args) EXPORT_OPTIONS(g_cmd_export_args) };
|
|
+ struct command_option options[] = { LOG_OPTIONS(lconf) COMMON_OPTIONS(g_cmd_export_args)
|
|
+ EXPORT_OPTIONS(g_cmd_export_args)
|
|
+ };
|
|
|
|
command_init(&cmd, options, sizeof(options) / sizeof(options[0]), argc, (const char **)argv, g_cmd_export_desc,
|
|
g_cmd_export_usage);
|
|
@@ -100,6 +94,11 @@ int cmd_export_main(int argc, const char **argv)
|
|
exit(EINVALIDARGS);
|
|
}
|
|
|
|
+ if (isula_libutils_log_enable(&lconf)) {
|
|
+ COMMAND_ERROR("log init failed");
|
|
+ exit(ECOMMON);
|
|
+ }
|
|
+
|
|
if (g_cmd_export_args.argc != 1) {
|
|
COMMAND_ERROR("Export requires exactly 1 container name");
|
|
exit(EINVALIDARGS);
|
|
diff --git a/src/cmd/isula/extend/pause.c b/src/cmd/isula/extend/pause.c
|
|
index 4d508e7b..c12eaa8c 100644
|
|
--- a/src/cmd/isula/extend/pause.c
|
|
+++ b/src/cmd/isula/extend/pause.c
|
|
@@ -71,23 +71,16 @@ int cmd_pause_main(int argc, const char **argv)
|
|
int i = 0;
|
|
int status = 0;
|
|
struct isula_libutils_log_config lconf = { 0 };
|
|
-
|
|
- lconf.name = argv[0];
|
|
- lconf.quiet = true;
|
|
- lconf.file = NULL;
|
|
- lconf.priority = "ERROR";
|
|
- lconf.driver = "stdout";
|
|
- if (isula_libutils_log_enable(&lconf)) {
|
|
- COMMAND_ERROR("log init failed");
|
|
- exit(ECOMMON);
|
|
- }
|
|
command_t cmd;
|
|
+
|
|
+ isula_libutils_default_log_config(argv[0], &lconf);
|
|
+
|
|
if (client_arguments_init(&g_cmd_pause_args)) {
|
|
COMMAND_ERROR("client arguments init failed");
|
|
exit(ECOMMON);
|
|
}
|
|
g_cmd_pause_args.progname = argv[0];
|
|
- struct command_option options[] = { COMMON_OPTIONS(g_cmd_pause_args) };
|
|
+ struct command_option options[] = { LOG_OPTIONS(lconf) COMMON_OPTIONS(g_cmd_pause_args) };
|
|
|
|
command_init(&cmd, options, sizeof(options) / sizeof(options[0]), argc, (const char **)argv, g_cmd_pause_desc,
|
|
g_cmd_pause_usage);
|
|
@@ -95,6 +88,11 @@ int cmd_pause_main(int argc, const char **argv)
|
|
exit(EINVALIDARGS);
|
|
}
|
|
|
|
+ if (isula_libutils_log_enable(&lconf)) {
|
|
+ COMMAND_ERROR("log init failed");
|
|
+ exit(ECOMMON);
|
|
+ }
|
|
+
|
|
if (g_cmd_pause_args.argc == 0) {
|
|
COMMAND_ERROR("Pause requires at least 1 container names");
|
|
exit(EINVALIDARGS);
|
|
diff --git a/src/cmd/isula/extend/resume.c b/src/cmd/isula/extend/resume.c
|
|
index c3c43760..7a25ee68 100644
|
|
--- a/src/cmd/isula/extend/resume.c
|
|
+++ b/src/cmd/isula/extend/resume.c
|
|
@@ -71,15 +71,7 @@ int cmd_resume_main(int argc, const char **argv)
|
|
int status = 0;
|
|
struct isula_libutils_log_config lconf = { 0 };
|
|
|
|
- lconf.name = argv[0];
|
|
- lconf.quiet = true;
|
|
- lconf.driver = "stdout";
|
|
- lconf.file = NULL;
|
|
- lconf.priority = "ERROR";
|
|
- if (isula_libutils_log_enable(&lconf)) {
|
|
- COMMAND_ERROR("Resume: log init failed");
|
|
- exit(ECOMMON);
|
|
- }
|
|
+ isula_libutils_default_log_config(argv[0], &lconf);
|
|
|
|
command_t cmd;
|
|
if (client_arguments_init(&g_cmd_resume_args)) {
|
|
@@ -87,7 +79,7 @@ int cmd_resume_main(int argc, const char **argv)
|
|
exit(ECOMMON);
|
|
}
|
|
g_cmd_resume_args.progname = argv[0];
|
|
- struct command_option options[] = { COMMON_OPTIONS(g_cmd_resume_args) };
|
|
+ struct command_option options[] = { LOG_OPTIONS(lconf) COMMON_OPTIONS(g_cmd_resume_args) };
|
|
|
|
command_init(&cmd, options, sizeof(options) / sizeof(options[0]), argc, (const char **)argv, g_cmd_resume_desc,
|
|
g_cmd_resume_usage);
|
|
@@ -95,6 +87,11 @@ int cmd_resume_main(int argc, const char **argv)
|
|
exit(EINVALIDARGS);
|
|
}
|
|
|
|
+ if (isula_libutils_log_enable(&lconf)) {
|
|
+ COMMAND_ERROR("log init failed");
|
|
+ exit(ECOMMON);
|
|
+ }
|
|
+
|
|
if (g_cmd_resume_args.argc == 0) {
|
|
COMMAND_ERROR("Pause requires at least 1 container names");
|
|
exit(EINVALIDARGS);
|
|
--
|
|
2.25.1
|
|
|