Commit c24dd6f8 authored by Stephen Morris's avatar Stephen Morris

[trac899] Initialise member variable before running constructor

The FreeBSD compiler complained that the member variable logger_
could not be constructed because the data type (log4cplus::Logger)
has no default constructor.  It is therefore initialized to point
to the log4cplus root logger (the one that is guaranteed to exist),
even though the LoggerImpl constructor may reset it immediately
afterwards.
parent dc44fdda
......@@ -42,8 +42,12 @@ using namespace std;
namespace isc {
namespace log {
// Constructor
LoggerImpl::LoggerImpl(const string& name)
// Constructor. Although it may be immediately reset, logger_ is initialized to
// the log4cplus root logger; at least one compiler requires that all member
// variables be constructed before the constructor is run, but log4cplus::Logger
// (the type of logger_) has no default constructor.
LoggerImpl::LoggerImpl(const string& name) :
logger_(log4cplus::Logger::getRoot())
{
// Initialize log4cplus if not already done
initLog4cplus();
......@@ -51,7 +55,7 @@ LoggerImpl::LoggerImpl(const string& name)
// Are we the root logger?
if (name == getRootLoggerName()) {
name_ = name;
logger_ = log4cplus::Logger::getRoot();
// logger_ already set to log4cplus root logger at this point
} else {
name_ = getRootLoggerName() + "." + name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment