Suppressing elog.c context messages (was Re: Wait free LW_SHARED acquisition) - Mailing list pgsql-hackers

From Andres Freund
Subject Suppressing elog.c context messages (was Re: Wait free LW_SHARED acquisition)
Date
Msg-id 20141219160604.GG5023@alap3.anarazel.de
Whole thread Raw
Responses Re: Suppressing elog.c context messages (was Re: Wait free LW_SHARED acquisition)
List pgsql-hackers
Hi,

When debugging lwlock issues I found PRINT_LWDEBUG/LOG_LWDEBUG rather
painful to use because of the amount of elog contexts/statements
emitted. Given the number of lwlock acquirations that's just not doable.

To solve that during development I've solved that by basically
replacing:   if (Trace_lwlocks)          elog(LOG, "%s(%s %d): %s", where, name, index, msg);

with something like
   if (Trace_lwlocks)   {       ErrorContextCallback *old_error_context_stack;
...       old_error_context_stack = error_context_stack;       error_context_stack = NULL;       ereport(LOG,
  (errhidestmt(true),               errmsg("%s(%s %d): %s", where, T_NAME(lock),
 
T_ID(lock), msg)));

I think it'd generally be useful to have something like errhidecontext()
akin to errhidestatement() to avoid things like the above.

The usecases wher eI see this as being useful is high volume debug
logging, not normal messages...

Greetings,

Andres Freund

--Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: NUMERIC private methods?
Next
From: Robert Haas
Date:
Subject: Re: NUMERIC private methods?