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

From: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
To: Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Override compile time log levels of specific messages/modules
Date: 2016-09-06 09:56:49
Message-ID: CABOikdMzM-7CH2Zp_UXfMf7eN-LvyEYwWUh==R9XUxuWk3-Y2g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 6, 2016 at 3:06 PM, Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com>
wrote:

>
> I think it's worth looking at how Java handles logging. We can't achieve
> an exact parallel in C as we don't really have a class hierarchy ... but we
> do have subsystems roughly grouped by file and directory structure.
>
> Sure. In some large, popular enterprise softwares I've worked with many
years ago, we used to define modules within each source file and then
manually assign distinct integer IDs to each message and then provide
various utilities to turn on/off specific messages or range of messages
within a module.

> Being able to promote/demote these or selective lower the log level
> threshold on a directory, file, function and line level would be
> exceedingly handy. Pretty much all of that can be magic'd up from macro
> output so hopefully no postprocessing should be needed. (Though only gcc
> has _FUNC_ or _FUNCTION_ I think so we'd have selective support there.)
>
Well, __FUNCTION__ expands to function name and lookup based on string
identifiers will always be costly, especially if you want to sprinkle the
code with lot many debug messages. Same with __FILE__. I believe we need an
unique integer constant to make it a fast, O(1) lookup. I couldn't find any
other method to do that when I wrote the facility and hence did what I did.

Thanks,
Pavan
--
Pavan Deolasee http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message K S, Sandhya (Nokia - IN/Bangalore) 2016-09-06 09:57:33 Re: Postgres abort found in 9.3.11
Previous Message Petr Jelinek 2016-09-06 09:55:18 Re: Logical Replication WIP