Re: Override compile time log levels of specific messages/modules

From: Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
Subject: Re: Override compile time log levels of specific messages/modules
Date: 2016-09-11 11:42:36
Message-ID: CAMsr+YGA9T82+KJSLfhA=82D2Y4J_WXgBgYoW=BFRzb5OMGLNw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11 Sep. 2016 11:31, "Jim Nasby" <Jim(dot)Nasby(at)bluetreble(dot)com> wrote:

> Actually, I wish this was a straight-up logging level feature, because I
need it all the time when debugging complicated user-level code.
Specifically, I wish there was a GUC that would alter
(client|log)_min_messages upon entering a specific function, either for
just that function or for anything that function subsequently called.

We have that or close to it, but it's restricted for security. IIRC you
can't SET log_min_messages as non superuser including as part of CREATE
FUNCTION ... SET. Presumably because lowering it would let the user hide
activity admins expect to be recorded. Raising it would let them possibly
DoS via log spam - though that argument is rather undermined by the ability
to write plpgsql that does RAISE in a tight loop.

I'd like to be able to let users make logging more detailed but not less,
so they can only SET it to something equal to or more detailed to what
their session has art the start. Should actually be pretty trivial to
implement too.

You can then SET at session level, function level, SET LOCAL, etc. If you
want to control it dynamically via GUC you add calls to your functions to
check a custom user GUC and SET log level accordingly. Using whatever logic
you like.

> Bonus points if you could also specify a regex that the message text had
to match.
>

An errfinish() hook would be nice for that.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-09-11 13:06:34 Re: Useless dependency assumption libxml2 -> libxslt in MSVC scripts
Previous Message Paul Guo 2016-09-11 09:56:33 Use nanosleep() for pg_usleep() on Unix/Linux?