#include <log/message_dictionary.h>
#include <log/message_types.h>
+#include <boost/make_shared.hpp>
+
#include <util/strutil.h>
using namespace std;
namespace isc {
namespace log {
-LoggerImpl*
+LoggerImplPtr
Logger::getLoggerPtr() {
if (!initialized_) {
lock_guard<mutex> lk(mutex_);
void
Logger::initLoggerImpl() {
if (isLoggingInitialized()) {
- loggerptr_ = new LoggerImpl(name_);
+ loggerptr_ = boost::make_shared<LoggerImpl>(name_);
} else {
isc_throw(LoggingNotInitialized, "attempt to access logging function "
"before logging has been initialized");
// Destructor.
Logger::~Logger() {
- delete loggerptr_;
-
- // The next statement is required for the Kea hooks framework, where a
- // statically-linked Kea loads and unloads multiple libraries. See the hooks
- // documentation for more details.
- loggerptr_ = 0;
}
// Get Version
#include <atomic>
#include <cassert>
#include <cstdlib>
-#include <string>
#include <cstring>
#include <mutex>
+#include <string>
#include <boost/static_assert.hpp>
#include <exceptions/exceptions.h>
+#include <log/logger_impl.h>
#include <log/logger_level.h>
#include <log/message_types.h>
#include <log/log_formatter.h>
/// \note Note also that there is no constructor taking a std::string. This
/// minimizes the possibility of initializing a static logger with a
/// string, so leading to problems mentioned above.
- Logger(const char* name) : loggerptr_(NULL), initialized_(false) {
+ Logger(const char* name) : loggerptr_(), initialized_(false) {
// Validate the name of the logger.
if (name == NULL) {
/// cause a "LoggingNotInitialized" exception to be thrown.
///
/// \return Returns pointer to implementation
- LoggerImpl* getLoggerPtr();
+ LoggerImplPtr getLoggerPtr();
/// \brief Initialize Underlying Implementation and Set loggerptr_
void initLoggerImpl();
///< Pointer to underlying logger
- LoggerImpl* loggerptr_;
+ LoggerImplPtr loggerptr_;
///< Copy of the logger name
char name_[MAX_LOGGER_NAME_SIZE + 1];
#include <string>
#include <map>
#include <utility>
+
+#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
isc::log::interprocess::InterprocessSync* sync_;
};
+typedef boost::shared_ptr<LoggerImpl> LoggerImplPtr;
+
} // namespace log
} // namespace isc