logging: split FileHandlerFactory into two classes
authorAdam Simpkins <simpkins@fb.com>
Thu, 7 Dec 2017 01:29:30 +0000 (17:29 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 7 Dec 2017 01:41:43 +0000 (17:41 -0800)
commit9e1a1ce16ace21118f180ae28ade5ead129093d4
tree48b8e95fc79bf3e767b032f02ebf35fe48945789
parentf805cad2ece30186014139b1a1dc71aa09a352c4
logging: split FileHandlerFactory into two classes

Summary:
Split FileHandlerFactory into separate FileHandlerFactory and
StreamHandlerFactory classes, where FileHandlerFactory only handles logging to
files by path name, and StreamHandlerFactory only supports logging to stdout or
stderr.

The primary motivation for this is to allow logging to stdout or stderr in some
cases without allowing arbitrary files to be opened by FileHandlerFactory.
This can be achieved now by registering StreamHandlerFactory but not
FileHandlerFactory.  This makes it safer to allow controlling logging
configuration via command line flags even in setuid binaries.

Reviewed By: yfeldblum

Differential Revision: D6494226

fbshipit-source-id: a3ec371ca4266424d07dff20be18e6e13c057593
12 files changed:
folly/Makefile.am
folly/experimental/logging/FileHandlerFactory.cpp
folly/experimental/logging/FileHandlerFactory.h
folly/experimental/logging/FileWriterFactory.cpp [new file with mode: 0644]
folly/experimental/logging/FileWriterFactory.h [new file with mode: 0644]
folly/experimental/logging/Init.cpp
folly/experimental/logging/Makefile.am
folly/experimental/logging/StreamHandlerFactory.cpp [new file with mode: 0644]
folly/experimental/logging/StreamHandlerFactory.h [new file with mode: 0644]
folly/experimental/logging/docs/Config.md
folly/experimental/logging/test/FileHandlerFactoryTest.cpp
folly/experimental/logging/test/fatal_test.py