proxygen
folly::TestLogHandlerFactory Class Reference

#include <TestLogHandler.h>

Inheritance diagram for folly::TestLogHandlerFactory:
folly::LogHandlerFactory

Public Member Functions

 TestLogHandlerFactory (StringPiece type)
 
StringPiece getType () const override
 
std::shared_ptr< LogHandlercreateHandler (const Options &options) override
 
std::shared_ptr< LogHandlerupdateHandler (const std::shared_ptr< LogHandler > &existingHandler, const Options &options) override
 
- Public Member Functions inherited from folly::LogHandlerFactory
virtual ~LogHandlerFactory ()=default
 
virtual std::shared_ptr< LogHandlerupdateHandler (FOLLY_MAYBE_UNUSED const std::shared_ptr< LogHandler > &existingHandler, const Options &options)
 

Private Attributes

std::string type_
 

Additional Inherited Members

- Public Types inherited from folly::LogHandlerFactory
using Options = std::unordered_map< std::string, std::string >
 

Detailed Description

A LogHandlerFactory to create TestLogHandler objects.

Definition at line 85 of file TestLogHandler.h.

Constructor & Destructor Documentation

folly::TestLogHandlerFactory::TestLogHandlerFactory ( StringPiece  type)
inlineexplicit

Definition at line 87 of file TestLogHandler.h.

References folly::Range< Iter >::str().

87 : type_{type.str()} {}
PskType type

Member Function Documentation

std::shared_ptr< LogHandler > folly::TestLogHandlerFactory::createHandler ( const Options options)
overridevirtual

Create a new LogHandler.

Implements folly::LogHandlerFactory.

Definition at line 31 of file TestLogHandler.cpp.

References type_.

32  {
33  return std::make_shared<TestLogHandler>(LogHandlerConfig{type_, options});
34 }
StringPiece folly::TestLogHandlerFactory::getType ( ) const
inlineoverridevirtual

Get the type name of this LogHandlerFactory.

The type field in the LogHandlerConfig for all LogHandlers created by this factory should match the type of the LogHandlerFactory.

The type of a LogHandlerFactory should never change. The returned StringPiece should be valid for the lifetime of the LogHandlerFactory.

Implements folly::LogHandlerFactory.

Definition at line 89 of file TestLogHandler.h.

References type_.

89  {
90  return type_;
91  }
std::shared_ptr< LogHandler > folly::TestLogHandlerFactory::updateHandler ( const std::shared_ptr< LogHandler > &  existingHandler,
const Options options 
)
override

Definition at line 36 of file TestLogHandler.cpp.

References folly::get_ptr().

38  {
39  // Only re-use an existing handler in-place if it is a TestLogHandler
40  // and if the new options contain reuse_handler
41  auto existing = std::dynamic_pointer_cast<TestLogHandler>(existingHandler);
42  if (!existing || !get_ptr(options, "reuse_handler")) {
43  return createHandler(options);
44  }
45 
46  existing->setOptions(options);
47  return existing;
48 }
const Map::mapped_type * get_ptr(const Map &map, const Key &key)
Definition: MapUtil.h:169
std::shared_ptr< LogHandler > createHandler(const Options &options) override

Member Data Documentation

std::string folly::TestLogHandlerFactory::type_
private

Definition at line 100 of file TestLogHandler.h.


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