Temporarily capture a file descriptor by redirecting it into a file. You can consume its entire output thus far via read(), incrementally via readIncremental(), or via callback using chunk_cob. Great for testing logging (see also glog*Pattern()).
Synopsis
Declared in <folly/testing/TestUtil.h>
class CaptureFD;
Type Aliases
Name |
Description |
Callback type invoked with each captured chunk of output. |
Member Functions
Name |
Description |
|
Begins capturing the given file descriptor by redirecting it into a file. |
|
Stops capturing and restores the file descriptor. |
Reads the whole file into a string, but does not remove the redirect. |
|
Read any bytes that were appended to the file since the last readIncremental. Great for testing line‐by‐line output. |
|
Restore the captured FD to its original state. It can be useful to do this before the destructor so that you can read() the captured data and log about it to the formerly captured stderr or stdout. |
Created with MrDocs