diff options
author | Francis Dupont <fdupont@isc.org> | 2015-05-17 01:25:30 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2015-05-17 01:25:30 +0200 |
commit | e6586db00d69686cd8a6061057f614690f36716e (patch) | |
tree | 90945e42e6805ffdbf28db6debc106e3db793031 | |
parent | [master] fixed ~ vs ~ typo (#3865) (diff) | |
download | kea-e6586db00d69686cd8a6061057f614690f36716e.tar.xz kea-e6586db00d69686cd8a6061057f614690f36716e.zip |
[3513] added static getVersion for log
-rw-r--r-- | src/lib/log/logger.cc | 8 | ||||
-rw-r--r-- | src/lib/log/logger.h | 5 | ||||
-rw-r--r-- | src/lib/log/logger_impl.cc | 13 | ||||
-rw-r--r-- | src/lib/log/logger_impl.h | 6 | ||||
-rw-r--r-- | src/lib/log/tests/logger_unittest.cc | 5 |
5 files changed, 33 insertions, 4 deletions
diff --git a/src/lib/log/logger.cc b/src/lib/log/logger.cc index c9840febb4..7979dc6684 100644 --- a/src/lib/log/logger.cc +++ b/src/lib/log/logger.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011, 2015 Internet Systems Consortium, Inc. ("ISC") // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above @@ -50,6 +50,12 @@ Logger::~Logger() { loggerptr_ = 0; } +// Get Version +std::string +Logger::getVersion() { + return (LoggerImpl::getVersion()); +} + // Get Name of Logger std::string diff --git a/src/lib/log/logger.h b/src/lib/log/logger.h index 0b24ae6288..d9126abb97 100644 --- a/src/lib/log/logger.h +++ b/src/lib/log/logger.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011, 2014 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above @@ -200,6 +200,9 @@ public: /// \brief Destructor virtual ~Logger(); + /// \brief Version + static std::string getVersion(); + /// \brief The formatter used to replace placeholders typedef isc::log::Formatter<Logger> Formatter; diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc index 0905e98122..c705aaeecd 100644 --- a/src/lib/log/logger_impl.cc +++ b/src/lib/log/logger_impl.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011,2014-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011, 2014-2015 Internet Systems Consortium, Inc. ("ISC") // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above @@ -19,10 +19,12 @@ #include <stdarg.h> #include <stdio.h> #include <cstring> +#include <sstream> #include <boost/lexical_cast.hpp> #include <boost/static_assert.hpp> #include <boost/algorithm/string.hpp> +#include <log4cplus/version.h> #include <log4cplus/configurator.h> #include <log4cplus/loggingmacros.h> @@ -84,6 +86,15 @@ LoggerImpl::~LoggerImpl() { delete sync_; } +/// \brief Version +std::string +LoggerImpl::getVersion() { + std::ostringstream ver; + ver << "log4plus "; + ver << log4cplus::versionStr; + return (ver.str()); +} + // Set the severity for logging. void LoggerImpl::setSeverity(isc::log::Severity severity, int dbglevel) { diff --git a/src/lib/log/logger_impl.h b/src/lib/log/logger_impl.h index d63141fb21..3e47b62ae0 100644 --- a/src/lib/log/logger_impl.h +++ b/src/lib/log/logger_impl.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011, 2015 Internet Systems Consortium, Inc. ("ISC") // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above @@ -77,6 +77,10 @@ public: virtual ~LoggerImpl(); + /// \brief Version + static std::string getVersion(); + + /// \brief Get the full name of the logger (including the root name) virtual std::string getName() { return (name_); diff --git a/src/lib/log/tests/logger_unittest.cc b/src/lib/log/tests/logger_unittest.cc index 2848b54142..b9cae00661 100644 --- a/src/lib/log/tests/logger_unittest.cc +++ b/src/lib/log/tests/logger_unittest.cc @@ -48,6 +48,11 @@ public: } }; +// Check version + +TEST_F(LoggerTest, Version) { + EXPECT_NO_THROW(Logger::getVersion()); +} // Checks that the logger is named correctly. |