Skip to content

Commit 111e29e

Browse files
committed
Adjust comment about %t and %s to cover %m as well. Some trivial
code beautification too.
1 parent b4cbd60 commit 111e29e

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/backend/utils/error/elog.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
*
4444
* IDENTIFICATION
45-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.160 2005/06/10 16:23:10 neilc Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.161 2005/06/10 20:48:54 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1333,10 +1333,7 @@ log_line_prefix(StringInfo buf)
13331333
/* go to char after '%' */
13341334
i++;
13351335
if (i >= format_len)
1336-
{
1337-
/* format error - ignore it */
1338-
break;
1339-
}
1336+
break; /* format error - ignore it */
13401337

13411338
/* process the option */
13421339
switch (Log_line_prefix[i])
@@ -1377,8 +1374,18 @@ log_line_prefix(StringInfo buf)
13771374
break;
13781375
case 'm':
13791376
{
1377+
/*
1378+
* Note: for %m, %t, and %s we deliberately use the
1379+
* C library's strftime/localtime, and not the
1380+
* equivalent functions from src/timezone. This
1381+
* ensures that all backends will report log entries
1382+
* in the same timezone, namely whatever C-library
1383+
* setting they inherit from the postmaster. If we
1384+
* used src/timezone then local settings of the
1385+
* TimeZone GUC variable would confuse the log.
1386+
*/
13801387
time_t stamp_time;
1381-
char strfbuf[128], msbuf[5];
1388+
char strfbuf[128], msbuf[8];
13821389
struct timeval tv;
13831390

13841391
gettimeofday(&tv, NULL);
@@ -1388,32 +1395,21 @@ log_line_prefix(StringInfo buf)
13881395
/* leave room for milliseconds... */
13891396
/* Win32 timezone names are too long so don't print them. */
13901397
#ifndef WIN32
1391-
"%Y-%m-%d %H:%M:%S %Z",
1398+
"%Y-%m-%d %H:%M:%S %Z",
13921399
#else
1393-
"%Y-%m-%d %H:%M:%S ",
1400+
"%Y-%m-%d %H:%M:%S ",
13941401
#endif
1395-
localtime(&stamp_time));
1402+
localtime(&stamp_time));
13961403

13971404
/* 'paste' milliseconds into place... */
1398-
sprintf(msbuf, ".%03d",
1399-
(int)(tv.tv_usec/1000));
1405+
sprintf(msbuf, ".%03d", (int) (tv.tv_usec/1000));
14001406
strncpy(strfbuf+19, msbuf, 4);
14011407

14021408
appendStringInfoString(buf, strfbuf);
14031409
}
14041410
break;
14051411
case 't':
14061412
{
1407-
/*
1408-
* Note: for %t and %s we deliberately use the C
1409-
* library's strftime/localtime, and not the
1410-
* equivalent functions from src/timezone. This
1411-
* ensures that all backends will report log entries
1412-
* in the same timezone, namely whatever C-library
1413-
* setting they inherit from the postmaster. If we
1414-
* used src/timezone then local settings of the
1415-
* TimeZone GUC variable would confuse the log.
1416-
*/
14171413
time_t stamp_time = time(NULL);
14181414
char strfbuf[128];
14191415

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy