Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb93f3a

Browse filesBrowse files
committed
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
1 parent a6964bc commit eb93f3a
Copy full SHA for eb93f3a

File tree

Expand file treeCollapse file tree

12 files changed

+172
-94
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+172
-94
lines changed

‎src/backend/access/gist/gist.c

Copy file name to clipboardExpand all lines: src/backend/access/gist/gist.c
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,9 @@ gistfixsplit(GISTInsertState *state, GISTSTATE *giststate)
11671167
Page page;
11681168
List *splitinfo = NIL;
11691169

1170-
elog(LOG, "fixing incomplete split in index \"%s\", block %u",
1171-
RelationGetRelationName(state->r), stack->blkno);
1170+
ereport(LOG,
1171+
(errmsg("fixing incomplete split in index \"%s\", block %u",
1172+
RelationGetRelationName(state->r), stack->blkno)));
11721173

11731174
Assert(GistFollowRight(stack->page));
11741175
Assert(OffsetNumberIsValid(stack->downlinkoffnum));

‎src/backend/access/nbtree/nbtpage.c

Copy file name to clipboardExpand all lines: src/backend/access/nbtree/nbtpage.c
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,9 +2151,10 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
21512151

21522152
if (leftsib == P_NONE)
21532153
{
2154-
elog(LOG, "no left sibling (concurrent deletion?) of block %u in \"%s\"",
2155-
target,
2156-
RelationGetRelationName(rel));
2154+
ereport(LOG,
2155+
(errmsg("no left sibling (concurrent deletion?) of block %u in \"%s\"",
2156+
target,
2157+
RelationGetRelationName(rel))));
21572158
if (target != leafblkno)
21582159
{
21592160
/* we have only a pin on target, but pin+lock on leafbuf */

‎src/backend/access/transam/xlog.c

Copy file name to clipboardExpand all lines: src/backend/access/transam/xlog.c
+68-32Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,9 +1811,10 @@ WaitXLogInsertionsToFinish(XLogRecPtr upto)
18111811
*/
18121812
if (upto > reservedUpto)
18131813
{
1814-
elog(LOG, "request to flush past end of generated WAL; request %X/%X, currpos %X/%X",
1815-
(uint32) (upto >> 32), (uint32) upto,
1816-
(uint32) (reservedUpto >> 32), (uint32) reservedUpto);
1814+
ereport(LOG,
1815+
(errmsg("request to flush past end of generated WAL; request %X/%X, current position %X/%X",
1816+
(uint32) (upto >> 32), (uint32) upto,
1817+
(uint32) (reservedUpto >> 32), (uint32) reservedUpto)));
18171818
upto = reservedUpto;
18181819
}
18191820

@@ -8532,16 +8533,30 @@ ShutdownXLOG(int code, Datum arg)
85328533
static void
85338534
LogCheckpointStart(int flags, bool restartpoint)
85348535
{
8535-
elog(LOG, "%s starting:%s%s%s%s%s%s%s%s",
8536-
restartpoint ? "restartpoint" : "checkpoint",
8537-
(flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
8538-
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
8539-
(flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "",
8540-
(flags & CHECKPOINT_FORCE) ? " force" : "",
8541-
(flags & CHECKPOINT_WAIT) ? " wait" : "",
8542-
(flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
8543-
(flags & CHECKPOINT_CAUSE_TIME) ? " time" : "",
8544-
(flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : "");
8536+
if (restartpoint)
8537+
ereport(LOG,
8538+
/* translator: the placeholders show checkpoint options */
8539+
(errmsg("restartpoint starting:%s%s%s%s%s%s%s%s",
8540+
(flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
8541+
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
8542+
(flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "",
8543+
(flags & CHECKPOINT_FORCE) ? " force" : "",
8544+
(flags & CHECKPOINT_WAIT) ? " wait" : "",
8545+
(flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
8546+
(flags & CHECKPOINT_CAUSE_TIME) ? " time" : "",
8547+
(flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : "")));
8548+
else
8549+
ereport(LOG,
8550+
/* translator: the placeholders show checkpoint options */
8551+
(errmsg("checkpoint starting:%s%s%s%s%s%s%s%s",
8552+
(flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
8553+
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
8554+
(flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "",
8555+
(flags & CHECKPOINT_FORCE) ? " force" : "",
8556+
(flags & CHECKPOINT_WAIT) ? " wait" : "",
8557+
(flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
8558+
(flags & CHECKPOINT_CAUSE_TIME) ? " time" : "",
8559+
(flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : "")));
85458560
}
85468561

85478562
/*
@@ -8591,25 +8606,46 @@ LogCheckpointEnd(bool restartpoint)
85918606
CheckpointStats.ckpt_sync_rels;
85928607
average_msecs = (long) ((average_sync_time + 999) / 1000);
85938608

8594-
elog(LOG, "%s complete: wrote %d buffers (%.1f%%); "
8595-
"%d WAL file(s) added, %d removed, %d recycled; "
8596-
"write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
8597-
"sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
8598-
"distance=%d kB, estimate=%d kB",
8599-
restartpoint ? "restartpoint" : "checkpoint",
8600-
CheckpointStats.ckpt_bufs_written,
8601-
(double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
8602-
CheckpointStats.ckpt_segs_added,
8603-
CheckpointStats.ckpt_segs_removed,
8604-
CheckpointStats.ckpt_segs_recycled,
8605-
write_msecs / 1000, (int) (write_msecs % 1000),
8606-
sync_msecs / 1000, (int) (sync_msecs % 1000),
8607-
total_msecs / 1000, (int) (total_msecs % 1000),
8608-
CheckpointStats.ckpt_sync_rels,
8609-
longest_msecs / 1000, (int) (longest_msecs % 1000),
8610-
average_msecs / 1000, (int) (average_msecs % 1000),
8611-
(int) (PrevCheckPointDistance / 1024.0),
8612-
(int) (CheckPointDistanceEstimate / 1024.0));
8609+
if (restartpoint)
8610+
ereport(LOG,
8611+
(errmsg("restartpoint complete: wrote %d buffers (%.1f%%); "
8612+
"%d WAL file(s) added, %d removed, %d recycled; "
8613+
"write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
8614+
"sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
8615+
"distance=%d kB, estimate=%d kB",
8616+
CheckpointStats.ckpt_bufs_written,
8617+
(double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
8618+
CheckpointStats.ckpt_segs_added,
8619+
CheckpointStats.ckpt_segs_removed,
8620+
CheckpointStats.ckpt_segs_recycled,
8621+
write_msecs / 1000, (int) (write_msecs % 1000),
8622+
sync_msecs / 1000, (int) (sync_msecs % 1000),
8623+
total_msecs / 1000, (int) (total_msecs % 1000),
8624+
CheckpointStats.ckpt_sync_rels,
8625+
longest_msecs / 1000, (int) (longest_msecs % 1000),
8626+
average_msecs / 1000, (int) (average_msecs % 1000),
8627+
(int) (PrevCheckPointDistance / 1024.0),
8628+
(int) (CheckPointDistanceEstimate / 1024.0))));
8629+
else
8630+
ereport(LOG,
8631+
(errmsg("checkpoint complete: wrote %d buffers (%.1f%%); "
8632+
"%d WAL file(s) added, %d removed, %d recycled; "
8633+
"write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
8634+
"sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
8635+
"distance=%d kB, estimate=%d kB",
8636+
CheckpointStats.ckpt_bufs_written,
8637+
(double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
8638+
CheckpointStats.ckpt_segs_added,
8639+
CheckpointStats.ckpt_segs_removed,
8640+
CheckpointStats.ckpt_segs_recycled,
8641+
write_msecs / 1000, (int) (write_msecs % 1000),
8642+
sync_msecs / 1000, (int) (sync_msecs % 1000),
8643+
total_msecs / 1000, (int) (total_msecs % 1000),
8644+
CheckpointStats.ckpt_sync_rels,
8645+
longest_msecs / 1000, (int) (longest_msecs % 1000),
8646+
average_msecs / 1000, (int) (average_msecs % 1000),
8647+
(int) (PrevCheckPointDistance / 1024.0),
8648+
(int) (CheckPointDistanceEstimate / 1024.0))));
86138649
}
86148650

86158651
/*

‎src/backend/libpq/auth.c

Copy file name to clipboardExpand all lines: src/backend/libpq/auth.c
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,9 +2131,10 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message **msg,
21312131
reply[i].resp_retcode = PAM_SUCCESS;
21322132
break;
21332133
default:
2134-
elog(LOG, "unsupported PAM conversation %d/\"%s\"",
2135-
msg[i]->msg_style,
2136-
msg[i]->msg ? msg[i]->msg : "(none)");
2134+
ereport(LOG,
2135+
(errmsg("unsupported PAM conversation %d/\"%s\"",
2136+
msg[i]->msg_style,
2137+
msg[i]->msg ? msg[i]->msg : "(none)")));
21372138
goto fail;
21382139
}
21392140
}

‎src/backend/libpq/hba.c

Copy file name to clipboardExpand all lines: src/backend/libpq/hba.c
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ check_same_host_or_net(SockAddr *raddr, IPCompareMethod method)
857857
errno = 0;
858858
if (pg_foreach_ifaddr(check_network_callback, &cn) < 0)
859859
{
860-
elog(LOG, "error enumerating network interfaces: %m");
860+
ereport(LOG,
861+
(errmsg("error enumerating network interfaces: %m")));
861862
return false;
862863
}
863864

‎src/backend/libpq/pqcomm.c

Copy file name to clipboardExpand all lines: src/backend/libpq/pqcomm.c
+37-19Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,8 @@ StreamConnection(pgsocket server_fd, Port *port)
750750
(struct sockaddr *) &port->laddr.addr,
751751
&port->laddr.salen) < 0)
752752
{
753-
elog(LOG, "getsockname() failed: %m");
753+
ereport(LOG,
754+
(errmsg("getsockname() failed: %m")));
754755
return STATUS_ERROR;
755756
}
756757

@@ -769,15 +770,17 @@ StreamConnection(pgsocket server_fd, Port *port)
769770
if (setsockopt(port->sock, IPPROTO_TCP, TCP_NODELAY,
770771
(char *) &on, sizeof(on)) < 0)
771772
{
772-
elog(LOG, "setsockopt(%s) failed: %m", "TCP_NODELAY");
773+
ereport(LOG,
774+
(errmsg("setsockopt(%s) failed: %m", "TCP_NODELAY")));
773775
return STATUS_ERROR;
774776
}
775777
#endif
776778
on = 1;
777779
if (setsockopt(port->sock, SOL_SOCKET, SO_KEEPALIVE,
778780
(char *) &on, sizeof(on)) < 0)
779781
{
780-
elog(LOG, "setsockopt(%s) failed: %m", "SO_KEEPALIVE");
782+
ereport(LOG,
783+
(errmsg("setsockopt(%s) failed: %m", "SO_KEEPALIVE")));
781784
return STATUS_ERROR;
782785
}
783786

@@ -808,7 +811,8 @@ StreamConnection(pgsocket server_fd, Port *port)
808811
if (getsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &oldopt,
809812
&optlen) < 0)
810813
{
811-
elog(LOG, "getsockopt(%s) failed: %m", "SO_SNDBUF");
814+
ereport(LOG,
815+
(errmsg("getsockopt(%s) failed: %m", "SO_SNDBUF")));
812816
return STATUS_ERROR;
813817
}
814818
newopt = PQ_SEND_BUFFER_SIZE * 4;
@@ -817,7 +821,8 @@ StreamConnection(pgsocket server_fd, Port *port)
817821
if (setsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &newopt,
818822
sizeof(newopt)) < 0)
819823
{
820-
elog(LOG, "setsockopt(%s) failed: %m", "SO_SNDBUF");
824+
ereport(LOG,
825+
(errmsg("setsockopt(%s) failed: %m", "SO_SNDBUF")));
821826
return STATUS_ERROR;
822827
}
823828
}
@@ -1677,8 +1682,9 @@ pq_setkeepaliveswin32(Port *port, int idle, int interval)
16771682
NULL)
16781683
!= 0)
16791684
{
1680-
elog(LOG, "WSAIoctl(SIO_KEEPALIVE_VALS) failed: %ui",
1681-
WSAGetLastError());
1685+
ereport(LOG,
1686+
(errmsg("WSAIoctl(%s) failed: %ui",
1687+
"SIO_KEEPALIVE_VALS", WSAGetLastError())));
16821688
return STATUS_ERROR;
16831689
}
16841690
if (port->keepalives_idle != idle)
@@ -1708,7 +1714,8 @@ pq_getkeepalivesidle(Port *port)
17081714
(char *) &port->default_keepalives_idle,
17091715
&size) < 0)
17101716
{
1711-
elog(LOG, "getsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR);
1717+
ereport(LOG,
1718+
(errmsg("getsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR)));
17121719
port->default_keepalives_idle = -1; /* don't know */
17131720
}
17141721
#else /* WIN32 */
@@ -1752,7 +1759,8 @@ pq_setkeepalivesidle(int idle, Port *port)
17521759
if (setsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
17531760
(char *) &idle, sizeof(idle)) < 0)
17541761
{
1755-
elog(LOG, "setsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR);
1762+
ereport(LOG,
1763+
(errmsg("setsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR)));
17561764
return STATUS_ERROR;
17571765
}
17581766

@@ -1763,7 +1771,8 @@ pq_setkeepalivesidle(int idle, Port *port)
17631771
#else
17641772
if (idle != 0)
17651773
{
1766-
elog(LOG, "setting the keepalive idle time is not supported");
1774+
ereport(LOG,
1775+
(errmsg("setting the keepalive idle time is not supported")));
17671776
return STATUS_ERROR;
17681777
}
17691778
#endif
@@ -1790,7 +1799,8 @@ pq_getkeepalivesinterval(Port *port)
17901799
(char *) &port->default_keepalives_interval,
17911800
&size) < 0)
17921801
{
1793-
elog(LOG, "getsockopt(%s) failed: %m", "TCP_KEEPINTVL");
1802+
ereport(LOG,
1803+
(errmsg("getsockopt(%s) failed: %m", "TCP_KEEPINTVL")));
17941804
port->default_keepalives_interval = -1; /* don't know */
17951805
}
17961806
#else
@@ -1833,7 +1843,8 @@ pq_setkeepalivesinterval(int interval, Port *port)
18331843
if (setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPINTVL,
18341844
(char *) &interval, sizeof(interval)) < 0)
18351845
{
1836-
elog(LOG, "setsockopt(%s) failed: %m", "TCP_KEEPINTVL");
1846+
ereport(LOG,
1847+
(errmsg("setsockopt(%s) failed: %m", "TCP_KEEPINTVL")));
18371848
return STATUS_ERROR;
18381849
}
18391850

@@ -1844,7 +1855,8 @@ pq_setkeepalivesinterval(int interval, Port *port)
18441855
#else
18451856
if (interval != 0)
18461857
{
1847-
elog(LOG, "setsockopt(%s) not supported", "TCP_KEEPINTVL");
1858+
ereport(LOG,
1859+
(errmsg("setsockopt(%s) not supported", "TCP_KEEPINTVL")));
18481860
return STATUS_ERROR;
18491861
}
18501862
#endif
@@ -1870,7 +1882,8 @@ pq_getkeepalivescount(Port *port)
18701882
(char *) &port->default_keepalives_count,
18711883
&size) < 0)
18721884
{
1873-
elog(LOG, "getsockopt(%s) failed: %m", "TCP_KEEPCNT");
1885+
ereport(LOG,
1886+
(errmsg("getsockopt(%s) failed: %m", "TCP_KEEPCNT")));
18741887
port->default_keepalives_count = -1; /* don't know */
18751888
}
18761889
}
@@ -1908,15 +1921,17 @@ pq_setkeepalivescount(int count, Port *port)
19081921
if (setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPCNT,
19091922
(char *) &count, sizeof(count)) < 0)
19101923
{
1911-
elog(LOG, "setsockopt(%s) failed: %m", "TCP_KEEPCNT");
1924+
ereport(LOG,
1925+
(errmsg("setsockopt(%s) failed: %m", "TCP_KEEPCNT")));
19121926
return STATUS_ERROR;
19131927
}
19141928

19151929
port->keepalives_count = count;
19161930
#else
19171931
if (count != 0)
19181932
{
1919-
elog(LOG, "setsockopt(%s) not supported", "TCP_KEEPCNT");
1933+
ereport(LOG,
1934+
(errmsg("setsockopt(%s) not supported", "TCP_KEEPCNT")));
19201935
return STATUS_ERROR;
19211936
}
19221937
#endif
@@ -1942,7 +1957,8 @@ pq_gettcpusertimeout(Port *port)
19421957
(char *) &port->default_tcp_user_timeout,
19431958
&size) < 0)
19441959
{
1945-
elog(LOG, "getsockopt(%s) failed: %m", "TCP_USER_TIMEOUT");
1960+
ereport(LOG,
1961+
(errmsg("getsockopt(%s) failed: %m", "TCP_USER_TIMEOUT")));
19461962
port->default_tcp_user_timeout = -1; /* don't know */
19471963
}
19481964
}
@@ -1980,15 +1996,17 @@ pq_settcpusertimeout(int timeout, Port *port)
19801996
if (setsockopt(port->sock, IPPROTO_TCP, TCP_USER_TIMEOUT,
19811997
(char *) &timeout, sizeof(timeout)) < 0)
19821998
{
1983-
elog(LOG, "setsockopt(%s) failed: %m", "TCP_USER_TIMEOUT");
1999+
ereport(LOG,
2000+
(errmsg("setsockopt(%s) failed: %m", "TCP_USER_TIMEOUT")));
19842001
return STATUS_ERROR;
19852002
}
19862003

19872004
port->tcp_user_timeout = timeout;
19882005
#else
19892006
if (timeout != 0)
19902007
{
1991-
elog(LOG, "setsockopt(%s) not supported", "TCP_USER_TIMEOUT");
2008+
ereport(LOG,
2009+
(errmsg("setsockopt(%s) not supported", "TCP_USER_TIMEOUT")));
19922010
return STATUS_ERROR;
19932011
}
19942012
#endif

‎src/backend/postmaster/bgworker.c

Copy file name to clipboardExpand all lines: src/backend/postmaster/bgworker.c
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ BackgroundWorkerStateChange(void)
250250
*/
251251
if (max_worker_processes != BackgroundWorkerData->total_slots)
252252
{
253-
elog(LOG,
254-
"inconsistent background worker state (max_worker_processes=%d, total_slots=%d",
255-
max_worker_processes,
256-
BackgroundWorkerData->total_slots);
253+
ereport(LOG,
254+
(errmsg("inconsistent background worker state (max_worker_processes=%d, total_slots=%d)",
255+
max_worker_processes,
256+
BackgroundWorkerData->total_slots)));
257257
return;
258258
}
259259

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.