From 123676075f4f4534ac99cd4e43317c1b6f27c897 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 19 Jan 2020 13:49:56 +0100 Subject: [PATCH] Add flog category for history *file* --- src/flog.h | 1 + src/history.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/flog.h b/src/flog.h index bd0bc3b3b..52be62a56 100644 --- a/src/flog.h +++ b/src/flog.h @@ -83,6 +83,7 @@ class category_list_t { category_t char_encoding{L"char-encoding", L"Character encoding issues"}; category_t history{L"history", L"Command history events"}; + category_t history_file{L"history-file", L"Reading/Writing the history file"}; category_t profile_history{L"profile-history", L"History performance measurements"}; diff --git a/src/history.cpp b/src/history.cpp index 89fbd199f..d9e1600bf 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -718,7 +718,7 @@ bool history_impl_t::rewrite_to_temporary_file(int existing_fd, int dst_fd) cons err = flush_to_fd(&buffer, dst_fd, 0); } if (err) { - debug(2, L"Error %d when writing to temporary history file", err); + FLOGF(history_file, L"Error %d when writing to temporary history file", err); } return err == 0; @@ -790,7 +790,7 @@ bool history_impl_t::save_internal_via_rewrite() { // The file has changed, so we're going to re-read it // Truncate our tmp_fd so we can reuse it if (ftruncate(tmp_fd, 0) == -1 || lseek(tmp_fd, 0, SEEK_SET) == -1) { - debug(2, L"Error %d when truncating temporary history file", errno); + FLOGF(history_file, L"Error %d when truncating temporary history file", errno); } } else { // The file is unchanged, or the new file doesn't exist or we can't read it @@ -804,16 +804,16 @@ bool history_impl_t::save_internal_via_rewrite() { struct stat sbuf; if (target_fd_after.valid() && fstat(target_fd_after.fd(), &sbuf) >= 0) { if (fchown(tmp_fd, sbuf.st_uid, sbuf.st_gid) == -1) { - debug(2, L"Error %d when changing ownership of history file", errno); + FLOGF(history_file, L"Error %d when changing ownership of history file", errno); } if (fchmod(tmp_fd, sbuf.st_mode) == -1) { - debug(2, L"Error %d when changing mode of history file", errno); + FLOGF(history_file, L"Error %d when changing mode of history file", errno); } } // Slide it into place if (wrename(tmp_name, *target_name) == -1) { - debug(2, L"Error %d when renaming history file", errno); + FLOGF(history_file, L"Error %d when renaming history file", errno); } // We did it @@ -1081,7 +1081,7 @@ void history_impl_t::populate_from_config_path() { ssize_t written = write(dst_fd.fd(), buf, static_cast(size)); if (written < 0) { // This message does not have high enough priority to be shown by default. - debug(2, L"Error when writing history file"); + FLOGF(history_file, L"Error when writing history file"); break; } }