On Thu, Dec 05, 2019 at 12:29:29PM +0900, Kyotaro Horiguchi wrote: > At Thu, 05 Dec 2019 12:06:54 +0900 (JST), Kyotaro Horiguchi > <horikyota....@gmail.com> wrote in >> So, (IIUC) do we replace fprintf()s for error reporting together (but >> maybe in a separate patch)?
I guess that we should do that at the end of the day. A lookup at the in-core tools I see three areas which stand out compared to the rest: - pg_waldump, and attached is a patch for it. - pgbench. However for this one we also have some status messages showing up in stderr output, and the TAP tests have dependencies with the output generated. This part is not plugged into the generic logging facility yet, and we have 162 places where fprintf/stderr is used, so that's kind of messy. - pg_standby. For this one, we may actually be closer to just remove it from the tree :) -- Michael
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index a05fbe6938..be4bf49499 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -142,8 +142,7 @@ open_file_in_directory(const char *directory, const char *fname) fd = open(fpath, O_RDONLY | PG_BINARY, 0); if (fd < 0 && errno != ENOENT) - fatal_error("could not open file \"%s\": %s", - fname, strerror(errno)); + fatal_error("could not open file \"%s\": %m", fname); return fd; } @@ -207,8 +206,8 @@ search_directory(const char *directory, const char *fname) else { if (errno != 0) - fatal_error("could not read file \"%s\": %s", - fname, strerror(errno)); + fatal_error("could not read file \"%s\": %m", + fname); else fatal_error("could not read file \"%s\": read %d of %zu", fname, r, (Size) XLOG_BLCKSZ); @@ -316,7 +315,7 @@ WALDumpOpenSegment(XLogSegNo nextSegNo, WALSegmentContext *segcxt, break; } - fatal_error("could not find file \"%s\": %s", fname, strerror(errno)); + fatal_error("could not find file \"%s\": %m", fname); return -1; /* keep compiler quiet */ } @@ -925,8 +924,7 @@ main(int argc, char **argv) /* validate path points to directory */ if (!verify_directory(waldir)) { - pg_log_error("path \"%s\" could not be opened: %s", - waldir, strerror(errno)); + pg_log_error("could not open directory \"%s\": %m", waldir); goto bad_argument; } } @@ -946,8 +944,7 @@ main(int argc, char **argv) waldir = directory; if (!verify_directory(waldir)) - fatal_error("could not open directory \"%s\": %s", - waldir, strerror(errno)); + fatal_error("could not open directory \"%s\": %m", waldir); } waldir = identify_target_directory(waldir, fname);
signature.asc
Description: PGP signature