proxygen
folly::StreamHandlerFactory::WriterFactory Class Reference
Inheritance diagram for folly::StreamHandlerFactory::WriterFactory:
folly::StandardLogHandlerFactory::WriterFactory folly::StandardLogHandlerFactory::OptionProcessor

Public Member Functions

bool processOption (StringPiece name, StringPiece value) override
 
std::shared_ptr< LogWritercreateWriter () override
 
- Public Member Functions inherited from folly::StandardLogHandlerFactory::OptionProcessor
virtual ~OptionProcessor ()
 

Public Attributes

std::string stream_
 
FileWriterFactory fileWriterFactory_
 

Detailed Description

Definition at line 25 of file StreamHandlerFactory.cpp.

Member Function Documentation

std::shared_ptr<LogWriter> folly::StreamHandlerFactory::WriterFactory::createWriter ( )
inlineoverridevirtual

Implements folly::StandardLogHandlerFactory::WriterFactory.

Definition at line 36 of file StreamHandlerFactory.cpp.

References folly::FileWriterFactory::createWriter(), fileWriterFactory_, folly::gen::move, and stream_.

36  {
37  // Get the output file to use
38  File outputFile;
39  if (stream_.empty()) {
40  throw std::invalid_argument(
41  "no stream name specified for stream handler");
42  } else if (stream_ == "stderr") {
43  outputFile = File{STDERR_FILENO, /* ownsFd */ false};
44  } else if (stream_ == "stdout") {
45  outputFile = File{STDOUT_FILENO, /* ownsFd */ false};
46  } else {
47  throw std::invalid_argument(to<std::string>(
48  "unknown stream \"",
49  stream_,
50  "\": expected one of stdout or stderr"));
51  }
52 
53  return fileWriterFactory_.createWriter(std::move(outputFile));
54  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::shared_ptr< LogWriter > createWriter(File file)
bool folly::StreamHandlerFactory::WriterFactory::processOption ( StringPiece  name,
StringPiece  value 
)
inlineoverridevirtual

Process an option.

This should return true if the option was processed successfully, or false if this is an unknown option name. It should throw an exception if the option name is known but there is a problem with the value.

Implements folly::StandardLogHandlerFactory::OptionProcessor.

Definition at line 28 of file StreamHandlerFactory.cpp.

References fileWriterFactory_, folly::FileWriterFactory::processOption(), folly::Range< Iter >::str(), and stream_.

28  {
29  if (name == "stream") {
30  stream_ = value.str();
31  return true;
32  }
34  }
bool processOption(StringPiece name, StringPiece value)
const char * name
Definition: http_parser.c:437
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)

Member Data Documentation

FileWriterFactory folly::StreamHandlerFactory::WriterFactory::fileWriterFactory_

Definition at line 57 of file StreamHandlerFactory.cpp.

Referenced by createWriter(), and processOption().

std::string folly::StreamHandlerFactory::WriterFactory::stream_

Definition at line 56 of file StreamHandlerFactory.cpp.

Referenced by createWriter(), and processOption().


The documentation for this class was generated from the following file: