Brian Silverman | f5f8d8e | 2015-12-06 18:39:12 -0500 | [diff] [blame] | 1 | #ifndef AOS_TESTING_TEST_LOGGING_H_ |
| 2 | #define AOS_TESTING_TEST_LOGGING_H_ |
| 3 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 4 | namespace aos::testing { |
Brian Silverman | f5f8d8e | 2015-12-06 18:39:12 -0500 | [diff] [blame] | 5 | |
| 6 | // Enables the logging framework for use during a gtest test. |
| 7 | // It will print out all WARNING and above messages all of the time. It will |
| 8 | // also print out all log messages when a test fails. |
| 9 | // This function only needs to be called once in each process (after gtest is |
| 10 | // initialized), however it can be called more than that. |
| 11 | void EnableTestLogging(); |
| 12 | |
| 13 | // Redirect the messages enabled by EnableTestLogging() function to a file. |
| 14 | // By default the messages are printed to standard output. |
Austin Schuh | 60e7794 | 2022-05-16 17:48:24 -0700 | [diff] [blame] | 15 | void SetLogFileName(const char *filename); |
Brian Silverman | f5f8d8e | 2015-12-06 18:39:12 -0500 | [diff] [blame] | 16 | |
| 17 | // Force the messages to be printed as they are handled by the logging |
| 18 | // framework. This can be useful for tests that hang where no messages would |
| 19 | // otherwise be printed. This is also useful for tests that do pass, but where |
| 20 | // we want to use graphing tools to verify what's happening. |
| 21 | void ForcePrintLogsDuringTests(); |
| 22 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 23 | } // namespace aos::testing |
Brian Silverman | f5f8d8e | 2015-12-06 18:39:12 -0500 | [diff] [blame] | 24 | |
| 25 | #endif // AOS_TESTING_TEST_LOGGING_H_ |