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.
19 #include <unordered_map>
21 #include <folly/Range.h>
27 class StandardLogHandler;
30 * StandardLogHandlerFactory contains helper methods for LogHandlerFactory
31 * implementations that create StandardLogHandler objects.
33 * StandardLogHandlerFactory does not derive from LogHandlerFactory itself.
35 class StandardLogHandlerFactory {
37 using Options = std::unordered_map<std::string, std::string>;
39 class OptionProcessor {
41 virtual ~OptionProcessor() {}
46 * This should return true if the option was processed successfully,
47 * or false if this is an unknown option name. It should throw an
48 * exception if the option name is known but there is a problem with the
51 virtual bool processOption(StringPiece name, StringPiece value) = 0;
54 class FormatterFactory : public OptionProcessor {
56 virtual std::shared_ptr<LogFormatter> createFormatter() = 0;
59 class WriterFactory : public OptionProcessor {
61 virtual std::shared_ptr<LogWriter> createWriter() = 0;
64 static std::shared_ptr<StandardLogHandler> createHandler(
66 WriterFactory* writerFactory,
67 const Options& options);