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; } }