mirror of
https://github.com/postgres/postgres.git
synced 2025-12-15 02:22:24 +03:00
Modularize log_connections output
Convert the boolean log_connections GUC into a list GUC comprised of the connection aspects to log. This gives users more control over the volume and kind of connection logging. The current log_connections options are 'receipt', 'authentication', and 'authorization'. The empty string disables all connection logging. 'all' enables all available connection logging. For backwards compatibility, the most common values for the log_connections boolean are still supported (on, off, 1, 0, true, false, yes, no). Note that previously supported substrings of on, off, true, false, yes, and no are no longer supported. Author: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/flat/CAAKRu_b_smAHK0ZjrnL5GRxnAVWujEXQWpLXYzGbmpcZd3nLYw%40mail.gmail.com
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "postmaster/postmaster.h"
|
||||
#include "replication/walsender.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "tcop/backend_startup.h"
|
||||
#include "utils/memutils.h"
|
||||
|
||||
/*----------------------------------------------------------------
|
||||
@@ -317,7 +318,8 @@ auth_failed(Port *port, int status, const char *logdetail)
|
||||
/*
|
||||
* Sets the authenticated identity for the current user. The provided string
|
||||
* will be stored into MyClientConnectionInfo, alongside the current HBA
|
||||
* method in use. The ID will be logged if log_connections is enabled.
|
||||
* method in use. The ID will be logged if log_connections has the
|
||||
* 'authentication' option specified.
|
||||
*
|
||||
* Auth methods should call this routine exactly once, as soon as the user is
|
||||
* successfully authenticated, even if they have reasons to know that
|
||||
@@ -349,7 +351,7 @@ set_authn_id(Port *port, const char *id)
|
||||
MyClientConnectionInfo.authn_id = MemoryContextStrdup(TopMemoryContext, id);
|
||||
MyClientConnectionInfo.auth_method = port->hba->auth_method;
|
||||
|
||||
if (Log_connections)
|
||||
if (log_connections & LOG_CONNECTION_AUTHENTICATION)
|
||||
{
|
||||
ereport(LOG,
|
||||
errmsg("connection authenticated: identity=\"%s\" method=%s "
|
||||
@@ -633,7 +635,8 @@ ClientAuthentication(Port *port)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Log_connections && status == STATUS_OK &&
|
||||
if ((log_connections & LOG_CONNECTION_AUTHENTICATION) &&
|
||||
status == STATUS_OK &&
|
||||
!MyClientConnectionInfo.authn_id)
|
||||
{
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user