logging: add AsyncFileWriter
authorAdam Simpkins <simpkins@fb.com>
Thu, 15 Jun 2017 18:03:57 +0000 (11:03 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 15 Jun 2017 18:06:06 +0000 (11:06 -0700)
commit82b71ca37d76487b5ee0b0e517576f6111d1d3ea
treefb1ade422e8424a548f35a95376a625f61af4b3d
parentcb238d299031affd40d234266415d0b6322b370a
logging: add AsyncFileWriter

Summary:
Add an AsyncFileWriter class that implements the LogWriter interface using a
separate I/O thread to write the log messages to a file descriptor.

This LogWriter implementation ensures that normal process threads will never
block due to logging I/O.  By default it will buffer up to 1MB of data.  If
log messages are generated faster than they can be written to the file, log
messages will be discarded once the buffer limit is exceeded.  The LogWriter
will emit a message into the file recording how many messages were discarded
where the dropped messages should have been.

The downside of this class is that unwritten log messages still in the buffer
will be lost when the program crashes.

Reviewed By: wez

Differential Revision: D5083107

fbshipit-source-id: c67226f4d0726675d480b03eae83a29c5c3431b2
CMakeLists.txt
folly/Makefile.am
folly/experimental/logging/AsyncFileWriter.cpp [new file with mode: 0644]
folly/experimental/logging/AsyncFileWriter.h [new file with mode: 0644]
folly/experimental/logging/Makefile.am
folly/experimental/logging/test/AsyncFileWriterTest.cpp [new file with mode: 0644]