Greetings,
Minor enhancement, but a valuable one imv. Hopefully there aren't any
issues with it. :)
Thanks!
Stephen
commit 3cb707aa9f228e629e7127625a76a223751a778b
Author: Stephen Frost <sfrost@snowman.net>
Date: Wed Jan 12 09:17:31 2011 -0500
Add support for logging the current role This adds a '%o' option to the log_line_prefix GUC which will log the
current role. The '%u' option only logs the Session user, which can be misleading, but it's valuable to have both
options.
*** a/doc/src/sgml/config.sgml
--- b/doc/src/sgml/config.sgml
***************
*** 3508,3513 **** local0.* /var/log/postgresql
--- 3508,3518 ---- <entry>yes</entry> </row> <row>
+ <entry><literal>%o</literal></entry>
+ <entry>Current role name</entry>
+ <entry>yes</entry>
+ </row>
+ <row> <entry><literal>%d</literal></entry> <entry>Database name</entry>
<entry>yes</entry>
*** a/src/backend/utils/error/elog.c
--- b/src/backend/utils/error/elog.c
***************
*** 1826,1831 **** log_line_prefix(StringInfo buf, ErrorData *edata)
--- 1826,1841 ---- appendStringInfoString(buf, username); } break;
+ case 'o':
+ if (MyProcPort)
+ {
+ const char *rolename = GetUserNameFromId(GetUserId());
+
+ if (rolename == NULL || *rolename == '\0')
+ rolename = _("[unknown]");
+ appendStringInfoString(buf, rolename);
+ }
+ break; case 'd': if (MyProcPort) {