Browse Source

[trac899] Remove "in function" argument from logger constructor

That was a hangover from the log4cxx implementation and appears not to
be needed in log4cplus.
Stephen Morris 14 years ago
parent
commit
50dd99f81e

+ 1 - 1
src/lib/log/logger.cc

@@ -31,7 +31,7 @@ namespace log {
 // Initialize Logger implementation.  Does not check whether the implementation
 // has already been initialized - that was done by the caller (getLoggerPtr()).
 void Logger::initLoggerImpl() {
-    loggerptr_ = new LoggerImpl(name_, infunc_);
+    loggerptr_ = new LoggerImpl(name_);
 }
 
 // Destructor.

+ 1 - 27
src/lib/log/logger.h

@@ -55,32 +55,7 @@ public:
     /// \param name Name of the logger.  If the name is that of the root name,
     /// this creates an instance of the root logger; otherwise it creates a
     /// child of the root logger.
-    ///
-    /// \param infunc This argument is present to get round a bug in some
-    /// implementations of the logging system.  If the logger is declared in
-    /// a function (such that it will be deleted when the function exits,
-    /// before the program ends), set this true.  If declared outside a
-    /// function (such that it gets deleted during program rundown), set false
-    /// (the default).\n
-    /// \n
-    /// The problems encountered was that during program rundown, one logging
-    /// implementation (log4cxx) threw a MutexException (this is described in
-    /// https://issues.apache.org/jira/browse/LOGCXX-322).  As this only occurs
-    /// during program rundown, the issue is not serious - it just looks bad to
-    /// have the program crash instead of shut down cleanly.\n
-    /// \n
-    /// If log4cxx is chosen as the implementation, this flag controls the
-    /// deletion of the underlying log4cxx data structures when the logger is
-    /// deleted.  Setting it false for externally-declared loggers inhibits
-    /// their deletion; so at program exit the memory is not reclaimed during
-    /// program rundown, only when the process is selected.  Setting it true
-    /// for loggers that will be deleted in the normal running of the program
-    /// enables their deletion - which causes no issues as the problem only
-    /// manifests itself during program rundown.
-    /// \n
-    /// The flag has no effect on non-log4cxx implementations.
-    Logger(const std::string& name, bool infunc = false) :
-        loggerptr_(NULL), name_(name), infunc_(infunc)
+    Logger(const std::string& name) : loggerptr_(NULL), name_(name)
     {}
 
     /// \brief Destructor
@@ -226,7 +201,6 @@ private:
 
     LoggerImpl*     loggerptr_;     ///< Pointer to the underlying logger
     std::string     name_;          ///< Copy of the logger name
-    bool            infunc_;        ///< Copy of the infunc argument
 };
 
 } // namespace log

+ 1 - 3
src/lib/log/logger_impl.cc

@@ -43,19 +43,17 @@ namespace log {
 
 
 // Constructor
-LoggerImpl::LoggerImpl(const std::string& name, bool)
+LoggerImpl::LoggerImpl(const std::string& name)
 {
     // Initialize log4cplus if not already done
     initLog4cplus();
 
     // Are we the root logger?
     if (name == getRootLoggerName()) {
-        is_root_ = true;
         name_ = name;
         logger_ = log4cplus::Logger::getRoot();
 
     } else {
-        is_root_ = false;
         name_ = getRootLoggerName() + "." + name;
         logger_ = log4cplus::Logger::getInstance(name_);
     }

+ 1 - 5
src/lib/log/logger_impl.h

@@ -62,10 +62,7 @@ public:
     /// Creates a logger of the specific name.
     ///
     /// \param name Name of the logger.
-    ///
-    /// \param exit_delete This argument is present to get round a bug in
-    /// the log4cxx implementation.  It is unused here.
-    LoggerImpl(const std::string& name, bool);
+    LoggerImpl(const std::string& name);
 
 
     /// \brief Destructor
@@ -183,7 +180,6 @@ private:
     /// system.
     static void initLog4cplus();
 
-    bool                is_root_;           ///< Is this BIND 10 root logger?
     std::string         name_;              ///< Full name of this logger
     std::string         fmt_name_;          ///< Formatted name for output
     log4cplus::Logger   logger_;            ///< Underlying log4cplus logger

+ 1 - 1
src/lib/log/logger_support.cc

@@ -107,7 +107,7 @@ initLogger(const string& root, isc::log::Severity severity, int dbglevel,
     // debug level.  This is the logger that has the name of the application.
     // All other loggers created in this application will be its children.
     setRootLoggerName(root);
-    Logger root_logger(isc::log::getRootLoggerName(), true);
+    Logger root_logger(isc::log::getRootLoggerName());
 
     // Set the severity associated with it.  If no other logger has a severity,
     // this will be the default.

+ 1 - 1
src/lib/log/tests/logger_support_test.cc

@@ -52,7 +52,7 @@ int main(int argc, char** argv) {
     int                 dbglevel = -1;              // Logger debug level
     const char*         localfile = NULL;           // Local message file
     int                 option;                     // For getopt() processing
-    Logger              logger_dlm("dlm", true);    // Another example logger
+    Logger              logger_dlm("dlm");          // Another example logger
 
     // Parse options
     while ((option = getopt(argc, argv, "s:d:")) != -1) {

+ 13 - 30
src/lib/log/tests/logger_unittest.cc

@@ -25,34 +25,17 @@ using namespace isc;
 using namespace isc::log;
 using namespace std;
 
-namespace isc {
-namespace log {
-
-/// \brief Test Logger
+/// \brief Logger Test
 ///
-/// This logger is a subclass of the logger class under test, but makes
-/// protected methods public (for testing)
-
-class TestLogger : public Logger {
-public:
-    /// \brief constructor
-    TestLogger(const string& name) : Logger(name, true)
-    {
-    }
-};
-
-} // namespace log
-} // namespace isc
-
+/// As the logger is only a shell around the implementation, this tests also
+/// checks the logger implementation class as well.
 
 class LoggerTest : public ::testing::Test {
 protected:
     LoggerTest()
-    {
-    }
-
-    ~LoggerTest() {
-    }
+    {}
+    ~LoggerTest()
+    {}
 };
 
 
@@ -81,14 +64,14 @@ TEST_F(LoggerTest, GetLogger) {
     const string name2 = "beta";
 
     // Instantiate two loggers that should be the same
-    TestLogger logger1(name1);
-    TestLogger logger2(name1);
+    Logger logger1(name1);
+    Logger logger2(name1);
     // And check they equal
     EXPECT_TRUE(logger1 == logger2);
 
     // Instantiate another logger with another name and check that it
     // is different to the previously instantiated ones.
-    TestLogger logger3(name2);
+    Logger logger3(name2);
     EXPECT_FALSE(logger1 == logger3);
 }
 
@@ -98,7 +81,7 @@ TEST_F(LoggerTest, Severity) {
 
     // Create a logger
     setRootLoggerName("test3");
-    TestLogger logger("alpha");
+    Logger logger("alpha");
 
     // Now check the levels
     logger.setSeverity(isc::log::NONE);
@@ -129,7 +112,7 @@ TEST_F(LoggerTest, DebugLevels) {
 
     // Create a logger
     setRootLoggerName("test4");
-    TestLogger logger("alpha");
+    Logger logger("alpha");
 
     // Debug level should be 0 if not at debug severity
     logger.setSeverity(isc::log::NONE, 20);
@@ -175,8 +158,8 @@ TEST_F(LoggerTest, SeverityInheritance) {
     // relationship if the loggers are named <parent> and <parent>.<child>.
 
     setRootLoggerName("test5");
-    TestLogger parent("alpha");
-    TestLogger child("alpha.beta");
+    Logger parent("alpha");
+    Logger child("alpha.beta");
 
     // By default, newly created loggers should have a level of DEFAULT
     // (i.e. default to parent)