/** * Destructor. Delete logger from the map. */ Logger::~Logger() { trace("~Logger destroyed"); // FIXME need to close handler Loggers::iterator it = loggers.find(getName()); if (it != loggers.end()) { loggers.erase(it); } }
void set_logger_level(LoggerId logger_id, LogLevel level) { MutexLock const l(_log_levels_mutex); auto const iter = _loggers.find(logger_id); if (iter == _loggers.end()) return; iter->second.get().set_log_level(level); }
LoggerPtr Logger::getRootLogger() { Loggers::iterator it = loggers.find(ROOT_LOGGER_NAME); if (it != loggers.end()) { return it->second; } else { LoggerPtr logger = new Logger(ROOT_LOGGER_NAME); logger->setParent(NULL); logger->setUseParent(false); loggers.insert(it, Loggers::value_type(ROOT_LOGGER_NAME, logger)); return logger; } }
LoggerPtr Logger::getLogger(const string &name) { Loggers::iterator it = loggers.find(name); if (it != loggers.end()) { return it->second; } else { LoggerPtr logger = new Logger(name); if (!logger->isRootLogger()) { LoggerPtr root = Logger::getRootLogger(); logger->setParent(root); logger->setUseParent(true); logger->setLevel(root->getLevel()); } logger->trace("Created logger"); loggers.insert(it, Loggers::value_type(name, logger)); return logger; } }