proxygen
folly::Logger Class Reference

#include <Logger.h>

Public Member Functions

 Logger (folly::StringPiece name)
 
 Logger (LogCategory *cat)
 
 Logger (LoggerDB *db, folly::StringPiece name)
 
LogCategorygetCategory () const
 

Private Attributes

LogCategory *const category_ {nullptr}
 

Detailed Description

Logger is the class you will use to specify the log category when logging messages with FB_LOG().

Logger is really just a small wrapper class that contains a pointer to the appropriate LogCategory object. It primarily exists as syntactic sugar to allow for easily looking up LogCategory objects.

Definition at line 157 of file Logger.h.

Constructor & Destructor Documentation

folly::Logger::Logger ( folly::StringPiece  name)
explicit

Construct a Logger for the given category name.

A LogCategory object for this category will be created if one does not already exist.

Definition at line 28 of file Logger.cpp.

References folly::LoggerDB::get(), and folly::LoggerDB::getCategory().

28 : Logger{LoggerDB::get().getCategory(name)} {}
LogCategory * getCategory(folly::StringPiece name)
Definition: LoggerDB.cpp:133
Logger(folly::StringPiece name)
Definition: Logger.cpp:28
static LoggerDB & get()
Definition: LoggerDB.cpp:112
folly::Logger::Logger ( LogCategory cat)
explicit

Construct a Logger pointing to an existing LogCategory object.

Definition at line 30 of file Logger.cpp.

30 : category_(cat) {}
auto cat
LogCategory *const category_
Definition: Logger.h:188
folly::Logger::Logger ( LoggerDB db,
folly::StringPiece  name 
)

Construct a Logger for a specific LoggerDB object, rather than the main singleton.

This is primarily intended for use in unit tests.

Definition at line 32 of file Logger.cpp.

References folly::LoggerDB::getCategory().

33  : Logger{db->getCategory(name)} {}
Logger(folly::StringPiece name)
Definition: Logger.cpp:28

Member Function Documentation

LogCategory* folly::Logger::getCategory ( ) const
inline

Get the LogCategory that this Logger refers to.

Definition at line 183 of file Logger.h.

References category_.

Referenced by TEST().

183  {
184  return category_;
185  }
LogCategory *const category_
Definition: Logger.h:188

Member Data Documentation

LogCategory* const folly::Logger::category_ {nullptr}
private

Definition at line 188 of file Logger.h.

Referenced by getCategory().


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