summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2017-10-12 11:31:34 +0530
committerJeff Darcy <jeff@pl.atyp.us>2017-11-09 13:24:19 +0000
commit52add0a289b8433547c5443b0dfd76e157275b10 (patch)
tree8a0439a43e4f7085ee746966c164b8ec11156d8e /xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
parent0821a57bd2e7518d1c8df2d4403a2dfbb8ee5b6b (diff)
features/libgfchangelog: Structured logging support
Structured logging infra is available in logging library with issue #240. Log messages with dynamic content are identified and converted to structured logging format(`gf_msg` to `gf_smsg` and `gf_log` to `gf_slog`) BUG: 1501054 Change-Id: I99b35396455a634f5267eb1379d481ea981e5494 Signed-off-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'xlators/features/changelog/lib/src/gf-changelog-journal-handler.c')
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-journal-handler.c71
1 files changed, 40 insertions, 31 deletions
diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
index a2d75cbbbfd..46f9bdae92c 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
@@ -555,10 +555,11 @@ gf_changelog_publish (xlator_t *this,
ret = sys_rename (to_path, dest);
if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, errno,
- CHANGELOG_LIB_MSG_RENAME_FAILED,
- "error moving %s to processing dir",
- to_path);
+ gf_smsg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_RENAME_FAILED,
+ "error moving changelog to processing dir",
+ "path=%s", to_path,
+ NULL);
}
out:
@@ -581,18 +582,21 @@ gf_changelog_consume (xlator_t *this,
ret = sys_stat (from_path, &stbuf);
if (ret || !S_ISREG(stbuf.st_mode)) {
ret = -1;
- gf_msg (this->name, GF_LOG_ERROR, errno,
- CHANGELOG_LIB_MSG_STAT_FAILED,
- "stat failed on changelog file: %s", from_path);
+ gf_smsg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_STAT_FAILED,
+ "stat failed on changelog file",
+ "path=%s", from_path,
+ NULL);
goto out;
}
fd1 = open (from_path, O_RDONLY);
if (fd1 < 0) {
- gf_msg (this->name, GF_LOG_ERROR, errno,
- CHANGELOG_LIB_MSG_OPEN_FAILED,
- "cannot open changelog file: %s",
- from_path);
+ gf_smsg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_OPEN_FAILED,
+ "cannot open changelog file",
+ "path=%s", from_path,
+ NULL);
goto out;
}
@@ -604,10 +608,11 @@ gf_changelog_consume (xlator_t *this,
fd2 = open (to_path, O_CREAT | O_TRUNC | O_RDWR,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd2 < 0) {
- gf_msg (this->name, GF_LOG_ERROR, errno,
- CHANGELOG_LIB_MSG_OPEN_FAILED,
- "cannot create ascii changelog file %s",
- to_path);
+ gf_smsg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_OPEN_FAILED,
+ "cannot create ascii changelog file",
+ "path=%s", to_path,
+ NULL);
goto close_fd;
} else {
ret = gf_changelog_decode (this, jnl, fd1,
@@ -622,10 +627,11 @@ gf_changelog_consume (xlator_t *this,
goto close_fd;
ret = sys_rename (to_path, dest);
if (ret)
- gf_msg (this->name, GF_LOG_ERROR, errno,
- CHANGELOG_LIB_MSG_RENAME_FAILED,
- "error moving %s to processing dir",
- to_path);
+ gf_smsg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_RENAME_FAILED,
+ "error moving changelog to processing dir",
+ "path=%s", to_path,
+ NULL);
}
/* remove it from .current if it's an empty file */
@@ -633,10 +639,11 @@ gf_changelog_consume (xlator_t *this,
/* zerob changelogs must be unlinked */
ret = sys_unlink (to_path);
if (ret)
- gf_msg (this->name, GF_LOG_ERROR, errno,
- CHANGELOG_LIB_MSG_UNLINK_FAILED,
- "could not unlink %s",
- to_path);
+ gf_smsg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_UNLINK_FAILED,
+ "could not unlink empty changelog",
+ "path=%s", to_path,
+ NULL);
}
}
@@ -855,10 +862,11 @@ gf_changelog_open_dirs (xlator_t *this, gf_changelog_journal_t *jnl)
jnl->jnl_working_dir);
ret = recursive_rmdir (jnl->jnl_current_dir);
if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, errno,
- CHANGELOG_LIB_MSG_FAILED_TO_RMDIR,
- "Failed to rmdir: %s",
- jnl->jnl_current_dir);
+ gf_smsg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_FAILED_TO_RMDIR,
+ "Failed to rmdir",
+ "path=%s", jnl->jnl_current_dir,
+ NULL);
goto out;
}
ret = mkdir_p (jnl->jnl_current_dir, 0600, _gf_false);
@@ -879,10 +887,11 @@ gf_changelog_open_dirs (xlator_t *this, gf_changelog_journal_t *jnl)
jnl->jnl_working_dir);
ret = recursive_rmdir (jnl->jnl_processing_dir);
if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, errno,
- CHANGELOG_LIB_MSG_FAILED_TO_RMDIR,
- "Failed to rmdir: %s",
- jnl->jnl_processing_dir);
+ gf_smsg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_FAILED_TO_RMDIR,
+ "Failed to rmdir",
+ "path=%s", jnl->jnl_processing_dir,
+ NULL);
goto out;
}