From 8217cfbd991856d25d73b0f7afcf43d99f90b653 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 28 Nov 2009 23:38:08 +0000 Subject: Add support for an application_name parameter, which is displayed in pg_stat_activity and recorded in log entries. Dave Page, reviewed by Andres Freund --- src/backend/utils/error/elog.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/backend/utils/error/elog.c') diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 5f30e783756..59fa07a379a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -42,7 +42,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.218 2009/10/17 00:24:50 mha Exp $ + * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.219 2009/11/28 23:38:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -68,6 +68,7 @@ #include "storage/ipc.h" #include "storage/proc.h" #include "tcop/tcopprot.h" +#include "utils/guc.h" #include "utils/memutils.h" #include "utils/ps_status.h" @@ -1798,6 +1799,16 @@ log_line_prefix(StringInfo buf, ErrorData *edata) /* process the option */ switch (Log_line_prefix[i]) { + case 'a': + if (MyProcPort) + { + const char *appname = application_name; + + if (appname == NULL || *appname == '\0') + appname = _("[unknown]"); + appendStringInfo(buf, "%s", appname); + } + break; case 'u': if (MyProcPort) { @@ -2103,6 +2114,11 @@ write_csvlog(ErrorData *edata) appendCSVLiteral(&buf, msgbuf.data); pfree(msgbuf.data); } + appendStringInfoCharMacro(&buf, ','); + + /* application name */ + if (application_name) + appendCSVLiteral(&buf, application_name); appendStringInfoChar(&buf, '\n'); -- cgit v1.2.3