blob: 3671aa1c5bdb71f7c6701039d44678ecc3afdec5 [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
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08006namespace aos::testing {
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05007
8// Enables the logging framework for use during a gtest test.
9// It will print out all WARNING and above messages all of the time. It will
10// also print out all log messages when a test fails.
11// This function only needs to be called once in each process (after gtest is
12// initialized), however it can be called more than that.
13void EnableTestLogging();
14
15// Redirect the messages enabled by EnableTestLogging() function to a file.
16// By default the messages are printed to standard output.
Austin Schuh60e77942022-05-16 17:48:24 -070017void SetLogFileName(const char *filename);
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -050018
19// Force the messages to be printed as they are handled by the logging
20// framework. This can be useful for tests that hang where no messages would
21// otherwise be printed. This is also useful for tests that do pass, but where
22// we want to use graphing tools to verify what's happening.
23void ForcePrintLogsDuringTests();
24
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080025} // namespace aos::testing
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -050026
27#endif // AOS_TESTING_TEST_LOGGING_H_