diff options
| author | Peter Eisentraut | 2020-12-04 13:25:23 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2020-12-04 13:25:23 +0000 |
| commit | eb93f3a0b633ad6afb0f37391b87f460c4b0663b (patch) | |
| tree | 7590fcb99e536615cfdb89bb4698b75f6e33ec14 /src/backend/postmaster | |
| parent | a6964bc1bb0793e20636ccb573cd2a5ad3ef7667 (diff) | |
Convert elog(LOG) calls to ereport() where appropriate
User-visible log messages should go through ereport(), so they are
subject to translation. Many remaining elog(LOG) calls are really
debugging calls.
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://www.postgresql.org/message-id/flat/92d6f545-5102-65d8-3c87-489f71ea0a37%40enterprisedb.com
Diffstat (limited to 'src/backend/postmaster')
| -rw-r--r-- | src/backend/postmaster/bgworker.c | 8 | ||||
| -rw-r--r-- | src/backend/postmaster/pgstat.c | 17 | ||||
| -rw-r--r-- | src/backend/postmaster/postmaster.c | 44 |
3 files changed, 42 insertions, 27 deletions
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index 5a9a0e34353..7ef6259eb50 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -250,10 +250,10 @@ BackgroundWorkerStateChange(void) */ if (max_worker_processes != BackgroundWorkerData->total_slots) { - elog(LOG, - "inconsistent background worker state (max_worker_processes=%d, total_slots=%d", - max_worker_processes, - BackgroundWorkerData->total_slots); + ereport(LOG, + (errmsg("inconsistent background worker state (max_worker_processes=%d, total_slots=%d)", + max_worker_processes, + BackgroundWorkerData->total_slots))); return; } diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 9bad14981b8..7c75a25d210 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -636,7 +636,8 @@ retry2: if (getsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF, (char *) &old_rcvbuf, &rcvbufsize) < 0) { - elog(LOG, "getsockopt(SO_RCVBUF) failed: %m"); + ereport(LOG, + (errmsg("getsockopt(%s) failed: %m", "SO_RCVBUF"))); /* if we can't get existing size, always try to set it */ old_rcvbuf = 0; } @@ -646,7 +647,8 @@ retry2: { if (setsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF, (char *) &new_rcvbuf, sizeof(new_rcvbuf)) < 0) - elog(LOG, "setsockopt(SO_RCVBUF) failed: %m"); + ereport(LOG, + (errmsg("setsockopt(%s) failed: %m", "SO_RCVBUF"))); } } @@ -6108,8 +6110,9 @@ backend_read_statsfile(void) /* Copy because timestamptz_to_str returns a static buffer */ filetime = pstrdup(timestamptz_to_str(file_ts)); mytime = pstrdup(timestamptz_to_str(cur_ts)); - elog(LOG, "stats collector's time %s is later than backend local time %s", - filetime, mytime); + ereport(LOG, + (errmsg("statistics collector's time %s is later than backend local time %s", + filetime, mytime))); pfree(filetime); pfree(mytime); } @@ -6251,9 +6254,9 @@ pgstat_recv_inquiry(PgStat_MsgInquiry *msg, int len) /* Copy because timestamptz_to_str returns a static buffer */ writetime = pstrdup(timestamptz_to_str(dbentry->stats_timestamp)); mytime = pstrdup(timestamptz_to_str(cur_ts)); - elog(LOG, - "stats_timestamp %s is later than collector's time %s for database %u", - writetime, mytime, dbentry->databaseid); + ereport(LOG, + (errmsg("stats_timestamp %s is later than collector's time %s for database %u", + writetime, mytime, dbentry->databaseid))); pfree(writetime); pfree(mytime); } diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index b7799ed1d24..5d09822c818 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -1207,8 +1207,9 @@ PostmasterMain(int argc, char *argv[]) NULL, NULL); if (err != kDNSServiceErr_NoError) - elog(LOG, "DNSServiceRegister() failed: error code %ld", - (long) err); + ereport(LOG, + (errmsg("DNSServiceRegister() failed: error code %ld", + (long) err))); /* * We don't bother to read the mDNS daemon's reply, and we expect that @@ -1466,7 +1467,8 @@ getInstallationPaths(const char *argv0) /* Locate the postgres executable itself */ if (find_my_exec(argv0, my_exec_path) < 0) - elog(FATAL, "%s: could not locate my own executable path", argv0); + ereport(FATAL, + (errmsg("%s: could not locate my own executable path", argv0))); #ifdef EXEC_BACKEND /* Locate executable backend before we change working directory */ @@ -4674,16 +4676,18 @@ retry: NULL); if (paramHandle == INVALID_HANDLE_VALUE) { - elog(LOG, "could not create backend parameter file mapping: error code %lu", - GetLastError()); + ereport(LOG, + (errmsg("could not create backend parameter file mapping: error code %lu", + GetLastError()))); return -1; } param = MapViewOfFile(paramHandle, FILE_MAP_WRITE, 0, 0, sizeof(BackendParameters)); if (!param) { - elog(LOG, "could not map backend parameter memory: error code %lu", - GetLastError()); + ereport(LOG, + (errmsg("could not map backend parameter memory: error code %lu", + GetLastError()))); CloseHandle(paramHandle); return -1; } @@ -4708,7 +4712,8 @@ retry: } if (cmdLine[sizeof(cmdLine) - 2] != '\0') { - elog(LOG, "subprocess command line too long"); + ereport(LOG, + (errmsg("subprocess command line too long"))); UnmapViewOfFile(param); CloseHandle(paramHandle); return -1; @@ -4725,8 +4730,9 @@ retry: if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)) { - elog(LOG, "CreateProcess call failed: %m (error code %lu)", - GetLastError()); + ereport(LOG, + (errmsg("CreateProcess() call failed: %m (error code %lu)", + GetLastError()))); UnmapViewOfFile(param); CloseHandle(paramHandle); return -1; @@ -4751,11 +4757,13 @@ retry: /* Drop the parameter shared memory that is now inherited to the backend */ if (!UnmapViewOfFile(param)) - elog(LOG, "could not unmap view of backend parameter file: error code %lu", - GetLastError()); + ereport(LOG, + (errmsg("could not unmap view of backend parameter file: error code %lu", + GetLastError()))); if (!CloseHandle(paramHandle)) - elog(LOG, "could not close handle to backend parameter file: error code %lu", - GetLastError()); + ereport(LOG, + (errmsg("could not close handle to backend parameter file: error code %lu", + GetLastError()))); /* * Reserve the memory region used by our main shared memory segment before @@ -5639,7 +5647,9 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname) if ((fp = fopen(OPTS_FILE, "w")) == NULL) { - elog(LOG, "could not create file \"%s\": %m", OPTS_FILE); + ereport(LOG, + (errcode_for_file_access(), + errmsg("could not create file \"%s\": %m", OPTS_FILE))); return false; } @@ -5650,7 +5660,9 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname) if (fclose(fp)) { - elog(LOG, "could not write file \"%s\": %m", OPTS_FILE); + ereport(LOG, + (errcode_for_file_access(), + errmsg("could not write file \"%s\": %m", OPTS_FILE))); return false; } |
