On Mon, Jun 9, 2008 at 5:49 AM, Ning Zhao <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm trying to write a thin wrapper for log4cxx for my own application, so
> that:
>
> 1. Instead of including log4xx-specific headers, I only need to include a
> MyAppLogging.h in each cpp of my source code.

In most places in the code that are doing logging you only have to
include one header <log4cxx\Logger.h>. I see no reason to eliminate
that.

> 2. For performance's sake, I consider the " if(logger->isXxxxxEnabled())"
> condition check should be used everywhere in my logging code. I want to just
> say "MyAppLog_INFO(logger, "some logging info")", and get "if
> (logger->isInfoEnabled()) LOG4CXX_INFO(logger, "some logging info...")" from
> my wrapper.

You aren't gaining any performance. LOG4CXX_INFO already does the if.

> 3. In my thin wrapper, all method calls would be simply directed to the
> Log4cxx implementation.

So what is the purpose of the wrapper?

> I am now studying the source code of apache.commons.logging and want to
> write a C++ clone with my own add-ons.

For what purpose? apache.commons.logging is actually considered bad by
some (See http://www.qos.ch/logging/thinkAgain.jsp for the opinion of
the creator of log4j).

The main reason for the existence of commons logging is to provide
pluggability between different logging frameworks. Do you have another
framework you want to plug in instead of log4cxx.

There might be a reason for a pluggable wrapper if you were writing a
library to be used by others and did not want to tie it to a
particular logger and instead let the user of the library implement
some logging interface.

> I'm new to C++, and it seems that the
> log4cxx implementation is a bit different from the log4j way. Above all, the
> smart pointers, templates....

That is mostly because of the differences between Java and C++. They
are there to make log4cxx more like log4j.

> How would a thin bridge for log4cxx best look
> like? Any tricky points caused by the smart pointers and templates I should
> pay attention to? Any hint would be highly appreciated! Thank you very much
> in advance

I think you first need to figure out why you want a wrapper.

-- 
Dale King

Reply via email to