blob: 5e01879080311542052ddef830fdd668615f017d [file] [log] [blame]
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05001#ifndef AOS_TESTING_TEST_LOGGING_H_
2#define AOS_TESTING_TEST_LOGGING_H_
3
Austin Schuh82c0c822019-05-27 19:55:20 -07004#include "aos/time/time.h"
5
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05006namespace aos {
7namespace testing {
8
9// Enables the logging framework for use during a gtest test.
10// It will print out all WARNING and above messages all of the time. It will
11// also print out all log messages when a test fails.
12// This function only needs to be called once in each process (after gtest is
13// initialized), however it can be called more than that.
14void EnableTestLogging();
15
16// Redirect the messages enabled by EnableTestLogging() function to a file.
17// By default the messages are printed to standard output.
Austin Schuh60e77942022-05-16 17:48:24 -070018void SetLogFileName(const char *filename);
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -050019
20// Force the messages to be printed as they are handled by the logging
21// framework. This can be useful for tests that hang where no messages would
22// otherwise be printed. This is also useful for tests that do pass, but where
23// we want to use graphing tools to verify what's happening.
24void ForcePrintLogsDuringTests();
25
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -050026} // namespace testing
27} // namespace aos
28
29#endif // AOS_TESTING_TEST_LOGGING_H_