Re: Override compile time log levels of specific messages/modules - Mailing list pgsql-hackers

From Pavan Deolasee
Subject Re: Override compile time log levels of specific messages/modules
Date
Msg-id CABOikdMzM-7CH2Zp_UXfMf7eN-LvyEYwWUh==R9XUxuWk3-Y2g@mail.gmail.com
Whole thread Raw
In response to Re: Override compile time log levels of specific messages/modules  (Craig Ringer <craig.ringer@2ndquadrant.com>)
List pgsql-hackers


On Tue, Sep 6, 2016 at 3:06 PM, Craig Ringer <craig.ringer@2ndquadrant.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

pgsql-hackers by date:

Previous
From: Petr Jelinek
Date:
Subject: Re: Logical Replication WIP
Next
From: Simon Riggs
Date:
Subject: Re: LOCK TABLE .. DEFERRABLE