From aa971f439d6eef9e52091915ce7ab1127aac1368 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Fri, 13 Sep 2013 15:20:45 +0530 Subject: logging: Expose set_log_file_path() in libglusterfs. This patch also changes the behavior of glfs_set_logging(). If logfile argument is not provided to glfs_set_logging(), libgfapi uses set_log_file_path() to create a logfile. Change-Id: I49ec66c7f16f5604ff2f7cf7b365b08a05b5460d BUG: 764890 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/5910 Reviewed-by: Anand Avati Tested-by: Anand Avati --- api/src/glfs.c | 20 ++++++++++++++------ api/src/glfs.h | 4 +++- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'api') diff --git a/api/src/glfs.c b/api/src/glfs.c index 4a41db937..1cb9088c0 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -475,17 +475,25 @@ int glfs_set_logging (struct glfs *fs, const char *logfile, int loglevel) { int ret = 0; + char *tmplog = NULL; + + if (!logfile) { + ret = gf_set_log_file_path (&fs->ctx->cmd_args); + if (ret) + goto out; + tmplog = fs->ctx->cmd_args.log_file; + } else { + tmplog = (char *)logfile; + } - if (logfile) { - /* passing ident as NULL means to use default ident for syslog */ - ret = gf_log_init (fs->ctx, logfile, NULL); - if (ret) - return ret; - } + ret = gf_log_init (fs->ctx, tmplog, NULL); + if (ret) + goto out; if (loglevel >= 0) gf_log_set_loglevel (loglevel); +out: return ret; } diff --git a/api/src/glfs.h b/api/src/glfs.h index 8aac6f8b6..fd44c2fc8 100644 --- a/api/src/glfs.h +++ b/api/src/glfs.h @@ -176,7 +176,9 @@ int glfs_set_volfile_server (glfs_t *fs, const char *transport, @fs: The 'virtual mount' object to be configured with the logging parameters. @logfile: The logfile to be used for logging. Will be created if it does not - already exist (provided system permissions allow.) + already exist (provided system permissions allow). If NULL, a new + logfile will be created in default log directory associated with + the glusterfs installation. @loglevel: Numerical value specifying the degree of verbosity. Higher the value, more verbose the logging. -- cgit