Changing the verbosity level in realtime

91 views
Skip to first unread message

Luc Simard

unread,
Oct 9, 2012, 5:50:43 PM10/9/12
to lo...@googlegroups.com

Hi,


I've tried to change the verbosity level in realtime but it doesn't work and I'm just curious to know if it is something that is possible to do, or it would require some modification to the code. Here's a sample of what I did to try this:


  3 static void function_1()

  4 {

  5     INFO("Hello people!");

  6     DBUG("My name is superman");

  7 }

  8

  9 int main(int argc, char* argv[]) {

 10

 11     LOGOG_INITIALIZE();

 12     LOGOG_SET_LEVEL(72);

 13

 14     logog::Target* logTarget = new logog::Cerr();

 15

 16     function_1();

 17     if(logTarget) delete logTarget;

 18

 19     LOGOG_SET_LEVEL(99);

 20     logTarget = new logog::Cerr();

 21    

 22     function_1();

 23     if(logTarget) delete logTarget;

 24

 25     LOGOG_SHUTDOWN();

 26     return 0;

 27 }


John Byrd

unread,
Oct 10, 2012, 8:33:00 PM10/10/12
to lo...@googlegroups.com
Howdy Luc,

Let me try to help out a bit...

The DBUG and INFO macros instantiate objects that represent those messages the first time they are called.  At that time, the log levels are set on the targets, and communications with the filters and outputs are negotiated.  Once those are negotiated, the current log level is not checked again.

So in essence the log level is checked exactly once per invocation of a log macro.

I took this approach because I wanted to make logging as fast as possible, with as few as possible run-time checks to see whether a log message would go out or not.

jwb


--
You received this message because you are subscribed to the Google Groups "Logog" group.
To view this discussion on the web visit https://groups.google.com/d/msg/logog/-/hArO7LBz-QkJ.
To post to this group, send email to lo...@googlegroups.com.
To unsubscribe from this group, send email to logog+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/logog?hl=en.



--
---

John Byrd
Gigantic Software
2102 Business Center Drive
Suite 210-D
Irvine, CA   92612-1001
http://www.giganticsoftware.com
T: (949) 892-3526 F: (206) 309-0850

Luc Simard

unread,
Oct 12, 2012, 9:37:54 PM10/12/12
to lo...@googlegroups.com
Thanks for your quick reply John and thanks for the information. 

I created a patch (see the attachment) that modify a bit how LOGLEVEL_SET_LEVEL behaves and give you the possibility to change the log level in real time. Let me know what you think.
logog-loglevel.patch

Guillaume Seguin

unread,
Jul 11, 2014, 10:22:43 PM7/11/14
to lo...@googlegroups.com
Just tried your patch, Luc, and it "works on my machine" (Windows 32 bit build).

What do you think of the patch John ? I can submit it in a github pull request if that makes it easier for you.

John Byrd

unread,
Jul 12, 2014, 5:05:34 AM7/12/14
to lo...@googlegroups.com
Would you mind terribly submitting a pull request to me on github?
Thank you so much Guillaume...
> To unsubscribe from this group and stop receiving emails from it, send an
> email to logog+un...@googlegroups.com.
>
> To post to this group, send email to lo...@googlegroups.com.
> Visit this group at http://groups.google.com/group/logog.
> For more options, visit https://groups.google.com/d/optout.

Guillaume Seguin

unread,
Jul 28, 2014, 9:51:06 PM7/28/14
to lo...@googlegroups.com
The code crashes in Release mode, only when run outside of the debugger... I will look into it. Talk to you on github!

--
Guillaume

John Byrd

unread,
Jul 29, 2014, 5:10:09 PM7/29/14
to lo...@googlegroups.com
I can see a bunch of pull requests on Github now. I'll need to take a
little time and look over these patches but superficially they look
really good. Thanks, everyone, for your efforts.

jwb

On Mon, Jul 28, 2014 at 6:51 PM, Guillaume Seguin
Reply all
Reply to author
Forward
0 new messages