proxygen
FileHandlerFactory.cpp
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  */
17 
21 
22 namespace folly {
23 
26  public:
28  if (name == "path") {
29  path_ = value.str();
30  return true;
31  }
32 
33  // TODO(T29811675): In the future it would be nice to support log rotation,
34  // and add parameters to control when the log file should be rotated.
35 
36  return fileWriterFactory_.processOption(name, value);
37  }
38 
39  std::shared_ptr<LogWriter> createWriter() override {
40  // Get the output file to use
41  if (path_.empty()) {
42  throw std::invalid_argument("no path specified for file handler");
43  }
45  File{path_, O_WRONLY | O_APPEND | O_CREAT});
46  }
47 
50 };
51 
52 std::shared_ptr<LogHandler> FileHandlerFactory::createHandler(
53  const Options& options) {
54  WriterFactory writerFactory;
56  getType(), &writerFactory, options);
57 }
58 
59 } // namespace folly
std::string str() const
Definition: Range.h:591
static std::shared_ptr< StandardLogHandler > createHandler(StringPiece type, WriterFactory *writerFactory, const Options &options)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
bool processOption(StringPiece name, StringPiece value)
std::shared_ptr< LogWriter > createWriter() override
const char * name
Definition: http_parser.c:437
StringPiece getType() const override
std::shared_ptr< LogHandler > createHandler(const Options &options) override
const char * string
Definition: Conv.cpp:212
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
std::shared_ptr< LogWriter > createWriter(File file)
bool processOption(StringPiece name, StringPiece value) override
std::unordered_map< std::string, std::string > Options