public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Eisentraut <[email protected]>
To: Tom Lane <[email protected]>
To: [email protected]
Subject: Re: Frontend error logging style
Date: Mon, 15 Nov 2021 20:08:19 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

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.





view thread (30+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Frontend error logging style
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox