6b0b9f83a15520000e9cf7d13a163b4e933d6a68
[folly.git] / folly / experimental / logging / LogConfig.h
1 /*
2  * Copyright 2004-present Facebook, Inc.
3  *
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
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #pragma once
17
18 #include <string>
19 #include <unordered_map>
20
21 #include <folly/experimental/logging/LogCategoryConfig.h>
22 #include <folly/experimental/logging/LogHandlerConfig.h>
23
24 namespace folly {
25
26 /**
27  * LogConfig contains configuration for the LoggerDB.
28  *
29  * This includes information about the log levels for log categories,
30  * as well as what log handlers are configured and which categories they are
31  * attached to.
32  */
33 class LogConfig {
34  public:
35   using CategoryConfigMap = std::unordered_map<std::string, LogCategoryConfig>;
36   using HandlerConfigMap = std::unordered_map<std::string, LogHandlerConfig>;
37
38   LogConfig() = default;
39   explicit LogConfig(
40       HandlerConfigMap handlerConfigs,
41       CategoryConfigMap catConfigs)
42       : handlerConfigs_{std::move(handlerConfigs)},
43         categoryConfigs_{std::move(catConfigs)} {}
44
45   const CategoryConfigMap& getCategoryConfigs() const {
46     return categoryConfigs_;
47   }
48   const HandlerConfigMap& getHandlerConfigs() const {
49     return handlerConfigs_;
50   }
51
52   bool operator==(const LogConfig& other) const;
53   bool operator!=(const LogConfig& other) const;
54
55  private:
56   HandlerConfigMap handlerConfigs_;
57   CategoryConfigMap categoryConfigs_;
58 };
59
60 } // namespace folly