Exemplo n.º 1
0
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;
  }
}
Exemplo n.º 2
0
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;
  }
}