Skip to content

Commit

Permalink
debug-log: add helpful hint msg about previous log_dir
Browse files Browse the repository at this point in the history
Logs on new log file path look like:

2018-12-14 18:30:31.154 14398 [CRIT] create_file_output:480:
  log file path now is '/var/log/gluster-block/tcmu-runner.log'
2018-12-14 18:30:31.154 14398 [CRIT] tcmu_resetup_log_file:748:
  you may find previous logs at '/var/log/tcmu-runner.log'

Signed-off-by: Prasanna Kumar Kalever <[email protected]>
  • Loading branch information
Prasanna Kumar Kalever committed Dec 14, 2018
1 parent dbf9fde commit a7f89f3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libtcmu_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,17 @@ static bool is_same_path(const char* path1, const char* path2)
int tcmu_resetup_log_file(char *log_dir)
{
int ret;
char old_logdir[PATH_MAX] = {'\0', };

if (is_same_path(tcmu_log_dir, log_dir)) {
tcmu_dbg("No changes to current log_dir: %s, skipping it.\n",
log_dir);
return 0;
}

if (tcmu_log_dir)
snprintf(old_logdir, PATH_MAX, "%s", tcmu_log_dir);

if (log_dir) {
ret = tcmu_log_dir_create(log_dir);
if (ret) {
Expand All @@ -738,6 +742,11 @@ int tcmu_resetup_log_file(char *log_dir)
if (ret < 0)
tcmu_err("Could not change log path to %s, ret:%d.\n",
log_dir, ret);

if (old_logdir[0])
tcmu_crit("you may find previous logs at '%s/%s'\n",
old_logdir, TCMU_LOG_FILENAME);

return ret;
}

Expand Down

0 comments on commit a7f89f3

Please sign in to comment.