diff options
author | Amar Tumballi <amar@gluster.com> | 2011-04-13 00:29:16 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-14 04:07:49 -0700 |
commit | 9b0374043ebe59fa638b8af330ea1d403503c143 (patch) | |
tree | 0673424ecd7b0cd410773f0e23e300396f31f23d | |
parent | 4d6e05f0aac70fbdec6b9530ed7b5d6ce4de0f03 (diff) |
cli: add log file for cli instead of '/dev/null'
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2737 (there is no log file for gluster cli)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2737
-rw-r--r-- | cli/src/cli.c | 20 | ||||
-rw-r--r-- | cli/src/cli.h | 1 |
2 files changed, 13 insertions, 8 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c index d6c801967..93fcd6204 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -225,10 +225,6 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) cmd_args = &ctx->cmd_args; - /* parsing command line arguments */ - cmd_args->log_file = "/dev/null"; - cmd_args->log_level = GF_LOG_NONE; - INIT_LIST_HEAD (&cmd_args->xlator_options); lim.rlim_cur = RLIM_INFINITY; @@ -242,10 +238,18 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) static int logging_init (glusterfs_ctx_t *ctx) { + int ret = 0; cmd_args_t *cmd_args = NULL; cmd_args = &ctx->cmd_args; + /* CLI should not have something to DEBUG after the release, + hence defaulting to INFO loglevel */ + cmd_args->log_level = GF_LOG_INFO; + + ret = gf_asprintf (&cmd_args->log_file, + DEFAULT_CLI_LOG_FILE_DIRECTORY "/cli.log"); + if (gf_log_init (cmd_args->log_file) == -1) { fprintf (stderr, "ERROR: failed to open logfile %s\n", cmd_args->log_file); @@ -615,14 +619,14 @@ main (int argc, char *argv[]) return EPERM; } - global_rpc = cli_rpc_init (&state); - if (!global_rpc) - goto out; - ret = logging_init (ctx); if (ret) goto out; + global_rpc = cli_rpc_init (&state); + if (!global_rpc) + goto out; + ret = cli_cmds_register (&state); if (ret) goto out; diff --git a/cli/src/cli.h b/cli/src/cli.h index 33a6fa187..f365da70f 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -33,6 +33,7 @@ #define CLI_GLUSTERD_PORT 24007 #define CLI_DEFAULT_CONN_TIMEOUT 120 #define CLI_DEFAULT_CMD_TIMEOUT 120 +#define DEFAULT_CLI_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" enum argp_option_keys { ARGP_DEBUG_KEY = 133, |