Change the log and output handling

Now the log file contains all the errors messages,
and all the tag lines.
This commit is contained in:
Andrea Mazzoleni 2015-02-02 23:39:46 +01:00
parent ce20be0ded
commit b5ce575981
32 changed files with 1127 additions and 1036 deletions

View file

@ -79,14 +79,14 @@ int search_file_compare(const void* void_arg, const void* void_data)
f = open(path, O_RDONLY | O_BINARY);
if (f == -1) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error opening file '%s'. %s.\n", path, strerror(errno));
ferr("Error opening file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (lseek(f, arg->offset, SEEK_SET) != arg->offset) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error seeking file '%s'. %s.\n", path, strerror(errno));
ferr("Error seeking file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -94,7 +94,7 @@ int search_file_compare(const void* void_arg, const void* void_data)
ret = read(f, arg->buffer, arg->read_size);
if (ret < 0 || (unsigned)ret != arg->read_size) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error reading file '%s'. %s.\n", path, strerror(errno));
ferr("Error reading file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -102,7 +102,7 @@ int search_file_compare(const void* void_arg, const void* void_data)
ret = close(f);
if (ret != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error closing file '%s'. %s.\n", path, strerror(errno));
ferr("Error closing file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -157,7 +157,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
d = opendir(dir);
if (!d) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error opening directory '%s'. %s.\n", dir, strerror(errno));
ferr("Error opening directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -176,7 +176,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
dd = readdir(d);
if (dd == 0 && errno != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error reading directory '%s'. %s.\n", dir, strerror(errno));
ferr("Error reading directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -220,7 +220,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
if (st.st_mode == 0) {
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
ferr("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -229,7 +229,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
/* get lstat info about the file */
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
ferr("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -258,7 +258,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
if (closedir(d) != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error closing directory '%s'. %s.\n", dir, strerror(errno));
ferr("Error closing directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}