proxygen
LogHandlerFactory.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017-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 <memory>
19 #include <string>
20 #include <unordered_map>
21 
22 #include <folly/CppAttributes.h>
23 #include <folly/Range.h>
24 
25 namespace folly {
26 
27 class LogHandler;
28 
30  public:
31  using Options = std::unordered_map<std::string, std::string>;
32 
33  virtual ~LogHandlerFactory() = default;
34 
44  virtual StringPiece getType() const = 0;
45 
49  virtual std::shared_ptr<LogHandler> createHandler(const Options& options) = 0;
50 
60  virtual std::shared_ptr<LogHandler> updateHandler(
61  FOLLY_MAYBE_UNUSED const std::shared_ptr<LogHandler>& existingHandler,
62  const Options& options) {
63  // Subclasses may override this with functionality to update an existing
64  // handler in-place. However, provide a default implementation that simply
65  // calls createHandler() to always create a new handler object.
66  return createHandler(options);
67  }
68 };
69 
70 } // namespace folly
virtual ~LogHandlerFactory()=default
virtual std::shared_ptr< LogHandler > updateHandler(FOLLY_MAYBE_UNUSED const std::shared_ptr< LogHandler > &existingHandler, const Options &options)
virtual std::shared_ptr< LogHandler > createHandler(const Options &options)=0
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
virtual StringPiece getType() const =0
#define FOLLY_MAYBE_UNUSED
Definition: CppAttributes.h:83
std::unordered_map< std::string, std::string > Options