logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christophe de VIENNE <cdevie...@alphacent.com>
Subject NDC
Date Wed, 16 Jun 2004 13:59:03 GMT
Hi,

I'm a new log4cxx user, so my proposition may have been already studied 
in the past.

I have an add'on suggestion do NDC:
The NDC interface has a push and a pop. I'm personnaly very lazy, and 
it's a pain to think of the pop() each time, even more if I want to be 
exception safe.
So I made up a little class which does it for me in it's destructor, 
which works the same way boost::mutex::scoped_lock does.
I think it would be usefull to have this class directly in NDC, so one 
could write :

void myfunction() {
  NDC::scoped_push push("mycontext");
  ...
}

Simple and efficient :-)

The implementation would be :

class LOG4CXX_EXPORT NDC
{
    ...
    public:
       class scoped_push
       {
            scoped_push(const String& message) {
              NDC::push(message);
            }
             ~scoped_push() {
                NDC::pop();
             }
       };
    ...
};


This is a very c++ way to do, so it would be a log4cxx specificity.
If you're interested I can produce a cleaner patch.

Regards,

Christophe



Mime
View raw message