Re: Frontend error logging style

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Frontend error logging style
Date: 2021-11-15 19:08:19
Message-ID: d783b5cf-b7db-fa4f-cfaf-5f0cfdd18a30@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 09.11.21 23:20, Tom Lane wrote:
> 2. What is the preferred style for adding extra lines to log messages?
> I see a lot of direct prints to stderr:
>
> pg_log_error("missing required argument: database name");
> fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
> exit(1);

This is mainly used for those few messages that are sort of a "global
standard".

> but a number of places have chosen to do this:
>
> pg_log_error("query failed: %s", PQerrorMessage(conn));
> pg_log_error("query was: %s", todo);
>
> and some places got creative and did this:
>
> pg_log_error("query failed: %s", PQerrorMessage(conn));
> pg_log_info("query was: %s", sql.data);

I can't decide between those two. It depends on how each program
handles the log level internally.

Some kind of "detail" system could be useful. But it would need to be
tied into the log level, layout, etc. I have not seen much inspiration
for this kind of thing in other logging libraries, so I didn't do
anything about it yet.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2021-11-15 19:09:54 Re: BUFFERS enabled by default in EXPLAIN (ANALYZE)
Previous Message Peter Eisentraut 2021-11-15 19:05:15 Re: Frontend error logging style