• Adam Simpkins's avatar
    logging: move object to string functions to their own header · 029911f0
    Adam Simpkins authored
    Summary:
    In LogStreamProcessor.h we previously had some `fallbackFormat()` functions
    that attempted to convert arbitrary objects to strings in case an exception
    was thrown when formatting them with `folly::format()`.
    
    These functions basically attempt to perform best-effort conversion that
    ideally should never fail (barring failure to append to the output string).
    These functions attempt to use `toAppend()` for the object, similar to how
    `folly::to<std::string>()` works.  However, if no `toAppend()` function is
    available, or if it throws an exception, they fall back to returning a generic
    string.
    
    This diff moves these functions to a separate header file to make it easier to
    re-use them in other parts of the code.  In particular I plan to update the
    `XCHECK_EQ()` and related macros to use these functions to format its
    arguments.
    
    Reviewed By: chadaustin
    
    Differential Revision: D14545304
    
    fbshipit-source-id: 053a504340ba4513abc9bec186a31ffaa03a943a
    029911f0
LoggerTest.cpp 14.6 KB