[bind10-dev] in order to build bind10-20120517 against log4cplus-1.1.0-rc5
John Lumby
jlumby at bluecatnetworks.com
Wed Jun 6 21:34:36 UTC 2012
JINMEI Tatuya wrote :
> John Lumby <jlumby at bluecatnetworks.com> wrote:
>
> > Yes, I think you are correct, my patch is not good. I am not sure what is the best correction.
> > Maybe the method could allocate a new string() and cast it to tstring, but I could not get that idea to work,
> > and in any case it would then leak memory unless reclaimed.
> >
> > I will see if I can find out the expected call usage for this method now that the log4cplus has changed it to return a ref.
>
> On a closer look at the code, I guess the returned object can simply
> be statically constructed:
[ ... ]
> static const tstring debug_tstring("DEBUG");
> static const tstring empty_tstring;
[ ... ]
Yes. I tried some variants of that but none avoided the warning.
I get confused by C++ strings... Yours compiles cleanly.
>
> In fact, they are essentially constants and especially in this
> particular case there are only two possible cases. So the cost of
> holding these should be marginal.
Thanks. So here is the corrected patch:
--- src/lib/log/logger_impl.cc.orig 2011-11-02 09:46:32.000000000 -0400
+++ src/lib/log/logger_impl.cc 2012-06-05 12:59:12.716099530 -0400
@@ -22,6 +22,7 @@
#include <boost/static_assert.hpp>
#include <log4cplus/configurator.h>
+#include <log4cplus/loggingmacros.h>
#include <log/logger.h>
#include <log/logger_impl.h>
--- src/lib/log/logger_level_impl.cc.orig 2011-11-02 09:46:32.000000000 -0400
+++ src/lib/log/logger_level_impl.cc 2012-06-06 17:29:42.508800849 -0400
@@ -185,20 +185,24 @@ LoggerLevelImpl::logLevelFromString(cons
// Convert logging level to string. If the level is a valid debug level,
// return the string DEBUG, else return the empty string.
-log4cplus::tstring
+log4cplus::tstring const &
LoggerLevelImpl::logLevelToString(log4cplus::LogLevel level) {
+
+ static const tstring debug_string("DEBUG");
+ static const tstring empty_string;
+
Level bindlevel = convertToBindLevel(level);
Severity& severity = bindlevel.severity;
int& dbglevel = bindlevel.dbglevel;
if ((severity == DEBUG) &&
((dbglevel >= MIN_DEBUG_LEVEL) && (dbglevel <= MAX_DEBUG_LEVEL))) {
- return (tstring("DEBUG"));
+ return (debug_string);
}
// Unknown, so return empty string for log4cplus to try other conversion
// functions.
- return (tstring());
+ return (empty_string);
}
// Initialization. Register the conversion functions with the LogLevelManager.
--- src/lib/log/logger_level_impl.h.orig 2012-03-19 14:55:01.000000000 -0400
+++ src/lib/log/logger_level_impl.h 2012-06-05 15:21:00.004301737 -0400
@@ -112,7 +112,7 @@ public:
/// \param level Extended logging level
///
/// \return Equivalent string.
- static log4cplus::tstring logLevelToString(log4cplus::LogLevel level);
+ static log4cplus::tstring const & logLevelToString(log4cplus::LogLevel level);
/// \brief Initialize extended logging levels
///
--- src/lib/log/logger_manager_impl.cc.orig 2012-05-08 12:55:34.000000000 -0400
+++ src/lib/log/logger_manager_impl.cc 2012-06-05 15:27:38.864311183 -0400
@@ -17,6 +17,7 @@
#include <log4cplus/logger.h>
#include <log4cplus/configurator.h>
+#include <log4cplus/hierarchy.h>
#include <log4cplus/consoleappender.h>
#include <log4cplus/fileappender.h>
#include <log4cplus/syslogappender.h>
More information about the bind10-dev
mailing list