コード例 #1
0
ファイル: JLogger.cpp プロジェクト: jeffedlund/rpc
            void JLogger::doSetParent(JLogger* newParent) {
                treeLock->lock();

                JLogger* ref = NULL;
                if (parent != NULL) {
                    JIterator* iter=NULL;
                    for (iter = parent->kids->iterator(); iter->hasNext(); ) {
                        ref = (JLogger*)iter->next();
                        if (ref == this) {
                            iter->remove();
                            break;
                        } else {
                            ref = NULL;
                        }
                    }
                    delete iter;
                }

                parent = newParent;
                if (parent->kids == NULL) {
                    parent->kids = new JArrayList();
                }
                parent->kids->add(parent);
                updateEffectiveLevel();
                treeLock->unlock();
            }
コード例 #2
0
ファイル: LogCategory.cpp プロジェクト: RcRonco/folly
void LogCategory::setLevelLocked(LogLevel level, bool inherit) {
  // Clamp the value to MIN_LEVEL and MAX_LEVEL.
  //
  // This makes sure that UNINITIALIZED is always less than any valid level
  // value, and that level values cannot conflict with our flag bits.
  level = constexpr_clamp(level, LogLevel::MIN_LEVEL, LogLevel::MAX_LEVEL);

  // Make sure the inherit flag is always off for the root logger.
  if (!parent_) {
    inherit = false;
  }
  auto newValue = static_cast<uint32_t>(level);
  if (inherit) {
    newValue |= FLAG_INHERIT;
  }

  // Update the stored value
  uint32_t oldValue = level_.exchange(newValue, std::memory_order_acq_rel);

  // Break out early if the value has not changed.
  if (oldValue == newValue) {
    return;
  }

  // Update the effective log level
  LogLevel newEffectiveLevel;
  if (inherit) {
    newEffectiveLevel = std::min(level, parent_->getEffectiveLevel());
  } else {
    newEffectiveLevel = level;
  }
  updateEffectiveLevel(newEffectiveLevel);
}
コード例 #3
0
ファイル: LogCategory.cpp プロジェクト: RcRonco/folly
void LogCategory::parentLevelUpdated(LogLevel parentEffectiveLevel) {
  uint32_t levelValue = level_.load(std::memory_order_acquire);
  auto inherit = (levelValue & FLAG_INHERIT);
  if (!inherit) {
    return;
  }

  auto myLevel = static_cast<LogLevel>(levelValue & ~FLAG_INHERIT);
  auto newEffectiveLevel = std::min(myLevel, parentEffectiveLevel);
  updateEffectiveLevel(newEffectiveLevel);
}
コード例 #4
0
ファイル: JLogger.cpp プロジェクト: jeffedlund/rpc
 void JLogger::setLevel(JLevel* newLevel) {
     treeLock->lock();
     levelObject = newLevel;
     updateEffectiveLevel();
     treeLock->unlock();
 }