2 * Copyright 2004-present Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #include <folly/experimental/logging/LogConfig.h>
20 bool LogConfig::operator==(const LogConfig& other) const {
21 return handlerConfigs_ == other.handlerConfigs_ &&
22 categoryConfigs_ == other.categoryConfigs_;
25 bool LogConfig::operator!=(const LogConfig& other) const {
26 return !(*this == other);
29 void LogConfig::update(const LogConfig& other) {
30 // Update handlerConfigs_ with all of the entries from the other LogConfig.
31 // Any entries already present in our handlerConfigs_ are replaced wholesale.
32 for (const auto& entry : other.handlerConfigs_) {
33 auto result = handlerConfigs_.insert(entry);
35 result.first->second = entry.second;
39 // Update categoryConfigs_ with all of the entries from the other LogConfig.
41 // Any entries already present in our categoryConfigs_ are merged: if the new
42 // configuration does not include handler settings our entry's settings are
44 for (const auto& entry : other.categoryConfigs_) {
45 auto result = categoryConfigs_.insert(entry);
47 auto* existingEntry = &result.first->second;
48 auto oldHandlers = std::move(existingEntry->handlers);
49 *existingEntry = entry.second;
50 if (!existingEntry->handlers.hasValue()) {
51 existingEntry->handlers = std::move(oldHandlers);