Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a8a8867

Browse files
committed
Add support for logging the current role.
Stephen Frost, with some editorialization by me.
1 parent b7a0b42 commit a8a8867

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

doc/src/sgml/config.sgml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3504,7 +3504,12 @@ local0.* /var/log/postgresql
35043504
</row>
35053505
<row>
35063506
<entry><literal>%u</literal></entry>
3507-
<entry>User name</entry>
3507+
<entry>Login user name</entry>
3508+
<entry>yes</entry>
3509+
</row>
3510+
<row>
3511+
<entry><literal>%U</literal></entry>
3512+
<entry>Current user name</entry>
35083513
<entry>yes</entry>
35093514
</row>
35103515
<row>

src/backend/utils/error/elog.c

+10
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,16 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
18261826
appendStringInfoString(buf, username);
18271827
}
18281828
break;
1829+
case 'U':
1830+
if (MyProcPort)
1831+
{
1832+
const char *username = GetUserNameFromId(GetUserId());
1833+
1834+
if (username == NULL || *username == '\0')
1835+
username = _("[unknown]");
1836+
appendStringInfoString(buf, username);
1837+
}
1838+
break;
18291839
case 'd':
18301840
if (MyProcPort)
18311841
{

0 commit comments

Comments
 (0)