Re: Frontend error logging style

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Daniel Gustafsson <daniel@yesql.se>, Andres Freund <andres@anarazel.de>, Robert Haas <robertmhaas@gmail.com>, Michael Paquier <michael@paquier.xyz>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-04-11T15:04:30Z
Lists: pgsql-hackers
On 08.04.22 22:26, Tom Lane wrote:
> I wrote:
>> One other loose end is bothering me: I stuck with logging.h's
>> original choice to put "if (likely())" or "if (unlikely())"
>> conditionals into the macros, but I rather suspect that that's
>> just a waste.  I think we should put a centralized level check
>> into logging.c, and get rid of at least the "if (likely())"
>> checks, because those are going to succeed approximately 100.0%
>> of the time.  Maybe there's an argument for keeping the unlikely()
>> ones.
> 
> Concretely, something like the attached.  As a simple check,
> I looked at the compiled size of pg_dump.  It went from
> 
>    text    data     bss     dec     hex filename
>   380298    4008    1384  385690   5e29a /home/postgres/testversion/bin/pg_dump
> 
> to
> 
>     text    data     bss     dec     hex filename
>   374954    4008    1384  380346   5cdba src/bin/pg_dump/pg_dump
> 
> for a savings of about 5K or 1.5%.  Not a huge amount, but
> not nothing either, especially considering that the existing
> coding isn't buying us anything.

Yeah, that seems ok to change.  The previous coding style is more useful 
if you have a lot of debug messages in a hot code path, but that usually 
doesn't apply to where this is used.



Commits

  1. logging: Also add the command prefix to detail and hint messages

  2. Remove not-very-useful early checks of __pg_log_level in logging.h.

  3. Improve frontend error logging style.

  4. Apply PGDLLIMPORT markings broadly.